Set multiple user approvals based on List collector variable with non-user values

Abilash Kankip1
Tera Contributor

I've a spreadsheet with more than 100 folder names as one column and the other column contains approvers (different approver for every 1 or more folders ). I've built a table to store those folder names as String field and a reference field referencing user table for approvers. And in the catalog, I added a list collector variable referencing this folder table.

 

How to set Approver User activity based on the folders selected on the catalog? And should wait for all the approvals to open a task for fulfillment with only the approved folder access to fulfill.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Abilash Kankip1 

if workflow then use this script

Also ensure it waits for Everyone to approve -> select this option

AnkurBawiskar_0-1743405137627.png

 

answer = [];
var selectedFolders = current.variables.u_sc_folder_access.toString();
var gr = new GlideRecord('u_folder_access');
gr.addQuery('sys_id', 'IN', selectedFolders);
gr.query();
while (gr.next()) {
    var approverSysId = gr.getValue('u_folder_access_approver');
    answer.push(approverSysId);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

13 REPLIES 13

@Abilash Kankip1 

you can use workflow IF activity and check this

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

I've used the below script but it's only checking if the first selected variable value starts with box and then only it's creating task after approval, if any other value selected it is going to the next check to create another task.


answer = ifScript();

function ifScript() {
    var gr = new GlideRecord('u_folder_access');
    gr.addQuery('sys_id', 'IN', current.variables.u_folder_name);
    gr.query();
    while (gr.next()) {
        if (gr.u_srvr_drcty_name.startsWith("Box")) {
            return 'yes';
        } else {
            return 'no';
        }

    }
}

 

AbilashKankip1_0-1743456078881.png

 

@Abilash Kankip1 

I believe I have answered your original question.
Please mark my response as correct and close the thread.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Abilash Kankip1 

Please enhance the script to check for all the variable values of that list collector

If my response helped please mark it correct and close the thread so that it benefits future readers.

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