Automatically Assign Users to Change Roles Using a CSV File in Change Requests

Automatically Assign Users to Change Roles Using a CSV File in Change Requests

When organizations scale, managing dynamic approval assignments for hundreds of Category-Subcategory-Item (CSI) combinations becomes cumbersome to maintain manually in code. This solution allows you to store role assignments in a CSV file and automatically assign users to change roles based on the selected CSI values in the request.

This approach eliminates the need to hardcode logic inside scripts and enables easy, spreadsheet-driven maintenance of approver mappings.

Why Use Roles for Approvals?

In traditional workflows, approval routing is often handled via conditional nodes with layered logic such as:


While this works, it becomes difficult to manage and scale as the number of CSI combinations grows.

This script moves the decision logic out of the workflow and into a centralized custom script. The right users are automatically assigned to roles based on CSI values, and in your workflow, you simply refer to these roles in approval nodes (e.g., "IT Head Approval", "Line Manager"). This greatly simplifies workflow design and reduces maintenance overhead.


With this CSV-based solution:

  • All CSI-role mappings are stored in a central spreadsheet.

  • The script reads the mappings dynamically and assigns users to roles.

  • Business teams can update mappings without editing the script—just update the CSV file


How It Works

  • The script fetches a .csv file stored in the /custom/ directory.

  • Parses the CSV content and structures it like a nested JSON (category → subcategory → item → roles).

  • Matches the selected CSI from the change request.

  • Assigns the corresponding users to predefined change roles.

  • Disables those fields to prevent manual editing.


Sample Script ( Attached ) along with a sample csv.


Regards,
Nandakumar Balaji,
Senior Product Manager, Enterprise Service Management.

                  New to ADSelfService Plus?