based on the Location value in the form how to set approver in the workflow using script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-17-2025 01:22 AM
Consider that in the catalog item there is 3 field -requester for, Location and additional comments, and in the location field there are 5 choices are there, so how to set approver in the workflow based on that 5 values using script.
Note- Location value from the feild availble in the form only not from requester's Location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-17-2025 01:33 AM
Hi @Pratiksha05,
you can use a custom table with 2 fields (location and approver) and based on location you can get the approver value in script, otherwise you can hardcode the approver name directly in workflow script for each location.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-17-2025 01:38 AM
Hello @Pratiksha05
Did you try using Approval - User activity in worfklow, if not give a try for it then in this activity while configuring you can use script which will have switch condition to decide your approver.
Below is sample code which can be place in script:
(function execute(current, previous /*null when async*/) {
var approver;
// Get the value of the Location field
var location = current.variables.location;
// Determine the approver based on the Location value
switch (location) {
case 'Location1':
approver = 'sys_id_of_approver1';
break;
case 'Location2':
approver = 'sys_id_of_approver2';
break;
case 'Location3':
approver = 'sys_id_of_approver3';
break;
case 'Location4':
approver = 'sys_id_of_approver4';
break;
case 'Location5':
approver = 'sys_id_of_approver5';
break;
default:
approver = 'default_approver_sys_id'; // Fallback approver
}
//Replace 'sys_id_of_approverX' with the actual sys_id of the approvers for each location.
// Set the approver in the workflow
current.approver = approver;
})(current, previous);
If you are going by flow designer then you can use If statement to check what value is selected and on basis of it trigger approval.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.