Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Approval via script in workflow editor

jyothi15
Tera Expert

I need help on script underlined.
I have various level of teams that needs to be send for approval. For the highlighted HMI Manger if anyone in the group can approve the request. How can I add anyone in the group can approve the request in script. If I add anyone in group can approve  in the activity, then  It is taking as anyone in the over approval list that has been sent.

In my case I should enable only for HMI Manager group , anyone can approve the request in HMI Manager group

answer = [];
var stations = current.variables.station;
var hmimanager = 'a677cb0b1b4d6910aa61fe6fdc4bcb4b';
var grST = new GlideRecord('u_hmi_support_stations');
grST.addEncodedQuery('sys_idIN' + stations);
grST.query();
while (grST.next()) {

if (grST.u_station_manager && grST.sys_id != '1e0ec3c71b8d6910aa61fe6fdc4bcba4' && grST.sys_id != '52faafea1b36f854aa61fe6fdc4bcbb2') {
answer.push(grST.u_station_manager.toString());
}
if (grST.u_station_manager) {
answer.push(hmimanager);
}
if (grST.sys_id == '52faafea1b36f854aa61fe6fdc4bcbb2') {
answer.push(grST.u_area_manager.toString());
}
//answer.push('hmimanager');*/
}

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@jyothi15 

can you explain with an example?

also update as this

answer = [];
var stations = current.variables.station;
var hmimanager = 'a677cb0b1b4d6910aa61fe6fdc4bcb4b';
var grST = new GlideRecord('u_hmi_support_stations');
grST.addEncodedQuery('sys_idIN' + stations);
grST.query();
while (grST.next()) {

if (grST.u_station_manager && grST.sys_id != '1e0ec3c71b8d6910aa61fe6fdc4bcba4' && grST.sys_id != '52faafea1b36f854aa61fe6fdc4bcbb2') {
answer.push(grST.u_station_manager.toString());
}
if (grST.u_station_manager) {
answer.push(hmimanager.toString());
}
if (grST.sys_id == '52faafea1b36f854aa61fe6fdc4bcbb2') {
answer.push(grST.u_area_manager.toString());
}
//answer.push('hmimanager');*/
}

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader