runasrole
Syntax
RunAsRole(role)
Arguments
role: text
Meaning
RunAsRole runs the adapl under a certain role. The function was introduced especially to allow an application setup where the current location and location history of an object cannot be edited manually or by means of search & replace, while only allowing it to be changed via the Change location task, which is more secure and also better because the Change location task at least always updates the location history.
The setup would then consist of adding some new role to the database, like ChangeLocation for example (but any descriptive role name will do) and subsequently setting Read access rights for role $REST in collect.inf for all current location and location history fields except the merged-in fields and the context field (which would block these fields from being edited in any way, even when filling in a new record) while you must also set Full access rights for your new role to the same fields. Now by adding the RunAsRole statement (RunAsRole(ChangeLocation) for example) to the beginning of the ChangeLocation adapl (which takes care of the Change location task), you make sure the adapl won't be hindered by the read-only rights and will have full access.
Example 1
RunAsRole('ChangeLocation')
Result
For all users, the adapl will be run under the ChangeLocation role and access rights set for this role anywhere in the Collections application or database structures will apply and determine what the adapl can or can't do. So for example, if the adapl writes a new value to tag 2A, then the ChangeLocation role should have at least Write access rights to that field in the data dictionary.