ftos.metadata.isAttributeRestricted
Checks if access to a record attribute is permitted within a specific security context. Attributes marked as isSecurable may have access controlled through security roles.
Syntax
Copy
ftos.metadata.isAttributeRestricted(record: any, attributeKey: string): boolean
| Parameter | Description |
|---|---|
record
|
JSON object that contains key - value pairs that represent a record's attributes. HINT Typical examples include records from fetch result sets, such as those returned by ftos.data.getById, ftos.data.getByQuery, or ftos.data.getByQueryAndCache. |
attributeKey
|
Name of the property within the record that matches the attribute you wish to check (the name of the attribute). |
Result
Returns a boolean:
- true if access to the specified attribute is restricted
- false if access is permitted
Examples
This example:
- Retrieves the current entity record using the ftos.data.getById method and stores it in the currentRecord variable.
- Checks if access to the address attribute is restricted and stores the result in the restricted variable.
- If access is restricted, displays a warning message to the user using the ftos.context.response.setMessage method.
Copy
var currentRecord = ftos.data.getById(ftos.context.entityName, ftos.context.id);
var restricted = ftos.metadata.isAttributeRestricted(currentRecord, 'address')
if (restricted){
ftos.context.response.setMessage("You don't have access to the address.")
}