Skip to main content

system.mes.role.saveRole

Description

Creates or updates a Role record in the system based on the provided parameters.

Syntax

system.mes.role.saveRole(**roleData)

Parameters

ParameterTypeNullableDescription
idString (ULID)TrueThe ULID of the role (optional, used for updating an existing role).
enabledBooleanTrueIndicates if the role is active and enabled.
notesStringTrueNotes related to the role.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.
securityLevelsList<String>FalseList of Ignition security levels required for this role.
permissionsList<String>FalseList of MES permissions granted by this role.
roleRequirementTypeEnumFalseSpecifies if all or any security levels are required to grant permissions. See RoleRequirementType enum.

Returns

Returns a JSON representation of the saved role.

Code Examples

# Generate the object structure for a new role object, set the initial arguments and save it
role = system.mes.role.newRole()
role['securityLevels'] = ['Authenticated/Roles/Administrator']
role['permissions'] = ['MATERIALS.WRITE', 'INVENTORY.READ']
role['roleRequirementType'] = 'ALL_OF'
savedRole = system.mes.role.saveRole(**role)

# Output the JSON representation of the saved role
print(savedRole)