In enterprise environments, change approval requirements vary depending on the type and impact of the change. Typically, organizations define approval workflows that are dependent on the Category, Subcategory, and Item selected in the change request.
This script enables automatic assignment of named users to roles based on these criteria. It supports two major use cases:
Automatically assigning users to roles in the change form.
Simplifying approval workflows by using roles to represent approvers.
By configuring users into roles through this script, you can leverage these role names in your change workflow’s approval nodes, eliminating the need for complex condition trees.
Often, organizations maintain approval logic directly inside workflows using Conditional Nodes such as:
Condition: Category = X → Yes
Subcategory = Y → Yes
Item = Z → Route to Approver A
This approach becomes hard to scale when there are many combinations of category, subcategory, and item. Instead, this script acts as a dynamic condition handler, assigning the correct user to a predefined role (e.g., "IT Head Approval", "Line Manager"). You can then simply reference the role name in the workflow approval node, and the right user will be picked automatically.
This decouples business logic from the workflow and makes it easier to manage, audit, and update.
The script reads the values of Category, Subcategory, and Item from the change request. Based on this combination, it:
Assigns users to roles like:
Change Owner
Line Manager
IT Head Approval
Change Reviewer
Disables the role fields to prevent manual overrides.
Once users are assigned to these roles, they can be referenced directly in approval workflows.
Tip: Make sure the form field names (
CATEGORY
,SUBCATEGORY
,ITEM and role names
) exactly match what's configured in your Change template.
Add a new mapping block under categoryInfo
for the desired values.
Define the users to be assigned for each role.
Example:
"category_D": {
"subcategory_D": {
"item_D": {
"Change_Owner": "Alex Roy",
"Line_Manager": "Meena Gupta",
"IT_Head_Approval": "Rahul Mehta",
"Change_Reviewer": "Meena Gupta"
}
}
}
If a new role like Security Head
needs to be included:
Add the key-value pair under each relevant item
block.
Add a corresponding $CS.setText()
line in the script.
Include the field in the $CS.disableField()
call if it should be locked from user editing.
Example:
$CS.setText("Security Head", categoryInfo[cat][subcat][item]["Security_Head"]);
$CS.disableField(["Security Head"]);