Flow designer script to add approver based on division

Community Alums
Not applicable

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]"; // 
  }
1 ACCEPTED SOLUTION

Shruti Khaire
Kilo Sage

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!

View solution in original post

7 REPLIES 7

Shruti Khaire
Kilo Sage

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!

Community Alums
Not applicable

Hi Sruthi thanks this approach works

Hi @Community Alums,

No worries happy to help!

Sandeep Rajput
Tera Patron
Tera Patron

@Community Alums Did you see any errors in the log? What happens when the step with above script executes does it trigger any approval record?