Multiple approval request based on List collector choices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 06:49 AM
Hi guys,
I am trying to build a script that would generate multiple approval requests according the user selection of a list collector variable type. What I have so far, is generating all the approval requests at once, so what I need is to the script identify what has been selected and only generate the approval request for those selections.
See the script below:
answer = myScript();
function myScript() {
var selectedoption = [];
var collector = current.variables.variablename.toString();
var list = collector.split(",");
for (var i = 0; i < list.length; i++) {
var gr = new GlideRecord('question_choice');
gr.addQuery('question.sys_id=NUMBEROFSYSID');
if (gr.get(list[i] == "SYSID")) { //sys ID of plant1
selectedoption.push('SYSID'); //sys ID of user1
}
if (gr.get(list[i] == "SYSID")) { //sys ID of plant2
selectedoption.push('SYSID'); //sys ID of user2
}
if (gr.get(list[i] == "SYSID")) { //sys ID of plant3
selectedoption.push('SYSID'); //sys ID of user3
}
if (gr.get(list[i] == "SYSID" || gr.get(list[i] == "SYSID"))) { //sys ID of Plant4 and plant5
selectedoption.push('SYSID'); //sys ID of user4
}
if (gr.next()) {
return selectedoption;
}
}
}
Thank you, appreciate any help.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 06:52 AM
Hi
You can use a Flow for this , refer to this :https://community.servicenow.com/community?id=community_Blog&sys_id=9379ad701b0c05d056b699b8bd4bcb02
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2022 07:05 AM
Hi