
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 04:29 AM
Hi Community,
I'm trying to add approvers in flow designer based on division here is the script but seems to be not working looking for some quick help
var requestorDept = fd_data._1__get_catalog_variables.v_division;
if (requestorDept == 'dept sys_id') { //
return "ApprovesAnyU[approver sys_id]"; //
} else if (requestorDept == 'dept sys_id') { //
return "ApprovesAnyU[approver sys_id]"; //
} else if (requestorDept == 'dept sys_id') { //
return "ApprovesAnyU[approver sys_id]"; //
} else if (requestorDept == 'dept sys_id') { //
return "ApprovesAnyU[approver sys_id]"; //
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 05:09 AM
Hello @Community Alums,
I had somewhat similar requirement where we used location table value to populate assignment group. I'll attach my code snippet below hope it helps.
var ritmSysId = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);
var location = rec.variables.printer_location.primary_location.getDisplayValue();
var assignmentgrp;
gs.log('testing'+ location);
if(location == 'Location_1'){
assignmentgrp="sys_id1";
}else if(location == 'Location_2'){
assignmentgrp="sys_id2";
}return assignmentgrp;
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 05:37 AM
the step is skipped and nothing happens after

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 05:49 AM
@Community Alums Can you replace the first line as follows and give it a try.
var requestorDept = fd_data._1__get_catalog_variables.v_division+''; //added an empty string to convert the reference to a string for comparision.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 05:34 AM
Hi @Community Alums
Please try below -
var requestorDept = fd_data._1__get_catalog_variables.v_division;
// Check division and return the appropriate approver role
if (requestorDept == 'dept sys_id 1') {
return "ApprovesAnyU[approver sys_id 1]";
} else if (requestorDept == 'dept sys_id 2') {
return "ApprovesAnyU[approver sys_id 2]";
} else if (requestorDept == 'dept sys_id 3') {
return "ApprovesAnyU[approver sys_id 3]";
} else if (requestorDept == 'dept sys_id 4') {
return "ApprovesAnyU[approver sys_id 4]";
}
// If no matching division, you might want to handle this case
// with a default approver or some error handling.
return "DefaultApproverRole[default_approver_sys_id]";
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar