SetSecurity

You can use the SetSecurity function to modify the security permissions of an Optiva object. This function grants either broader or more restricted access to the specified object by updating its security settings.

When to use

You can use this function to:

  • Modify security permissions for an object.
  • Apply security changes during workflow processing or automation.

Syntax

long SetSecurity(string objSymbol, string objectKey, <datatype> objectSecurity, <datatype> groupSecurity, <datatype> roleSecurity)

Parameters

Parameter Type Required Description
objSymbol string Yes

The symbol of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
objKey string Optional

The key of the object.

Note: You can use empty quotation marks ("") for the current workflow symbol.
ownerSecurity string or int Yes The owner security level.
Note: You can use security value (0, 3, 7, 15) or empty string "" to leave unchanged.
groupSecurity string or int Yes Group security level.
Note: You can use security value (0, 3, 7, 15) or empty string "" to leave unchanged.

Security Values

Value Access Level Permissions
0 No Access No permissions.
3 Read/Copy Can view and copy the object.
7 Read/Copy/Write Can view, copy, and modify the object.
15 Read/Copy/Write/Delete Full access including delete.
"" (empty string) Unchanged Leaves current security setting unchanged.

Return Value

The application returns a value greater than zero (0) if the operation is successful.

Impact

  • Changes are persisted and affect all users
  • May restrict or grant access to users based on new settings

Prerequisites

  • The security values must be valid. (0, 3, 7, 15, or empty string)
  • Use of the function does not surpass the users basic role or object security permissions.
  • If the user never has access to a form > 3, setting a value of 7 using SetSecurity does not grant write access.

Examples

Example 1
Set security on item.
SetSecurity("ITEM", "ITEM1" , 7, 7, 0);
Description
This example grants full access (7 = Read/Copy/Write) to the Owner, and read/copy access (7) to the Group, while denying access (0) to the Role for the item "ITEM1".
Example 2
Set Security on Formula.
SetSecurity("FORMULA", FORMULA1, "", 7, "");
Description
This example sets security permissions on the formula identified by the variable FORMULA1. It grants full access (7 = Read/Copy/Write) to the Owner, while leaving Group and Role security unchanged (empty strings mean no change).
Example 3
Set security on current object.
SetSecurity("", "", 7, 3, 3);
Description
This example grants full access(7 = Read/Copy/Write) to owner, read/copy access to Group and Role for current object on which workflow is launched.