Script to trigger workflow approval based on variable

Tyler Jones
Tera Contributor
I've been working on a catalog item for file share access. I have UI policy actions that only show the correct options based on what drive they select.
 
I created two select boxes:
1. What drive do they need access to? (two options - Y or Z)
2. What folder? (if Y was selected, 25 options are displayed - if Z was selected, 15 options are displayed)
 
For each folder, there will be a different approver. I can't use Department Head or Primary Contact because they are tied to the Requested_For user. We need approval from the person over the requested folder.
 
I am not as familiar with creating tables, so I was wondering if I could just create a hidden field that changes based on what folder is selected and then have the workflow call that field for approval?
 
For example - Y:\HR would populate Bob Jones in the hidden field (let's say it's "dept_approver"), then the Approval - User step on the workflow could call the dept_approver variable.
 
If someone knows a script, that would be amazing. Thanks!
3 REPLIES 3

AnubhavRitolia
Mega Sage
Mega Sage

Hi Tyler,

If you have 2 static approvers for Y and Z folder. Lets say Bob Jones for Y folder and Tommy Hill for Z.

you can use 2 parallel IF activities and in advance condition you can check the value of variable 'What drive do they need access to?' and if it is Y than move user approval to Bob Jones. if it is Z than move user approval to Tommy Hill.

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

That's where the complexity is. Each choice from both questions requires a different user to approve.

Oh you means 25+15 = 40 approvers.

I that case better to react custom Table with 3 columns (Drive access, Folder, Approval).

Than you can use Run Script activity and you GlideRecord to query above created table and create Approval record accordingly.

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023