ServiceNow Flow designer to look in to a table field and send the Approvals

Vasu2
Tera Contributor

In the flow designer, I am trying to achieve a scenario where I am trying to pull all the user IDs which is inside the string field in a table and the string format is {"abcd": ["user_id1"], "efgh":["user_id2"]} and send the approvals at a time for all the user IDs . 
Can anyone help me on this...?

8 REPLIES 8

Chaitanya ILCR
Kilo Patron

Hi @Vasu2 ,

 

I am taking incident for achieving this I have pasted the string in the incident's short description and replace user_id with actual user ids

ChaitanyaILCR_0-1742095503196.png

 

1. I have created a flow variable

ChaitanyaILCR_1-1742095599861.png

 

2. use set variable flow logic and assign the value to the flow variable using the script

ChaitanyaILCR_2-1742095771300.png

3. use lookup records action and use user id(sys_id if sysid is used in the mentioned string) is one of

ChaitanyaILCR_3-1742095897798.png

 

4. use ask for approval action and use the lookup records as a v

ChaitanyaILCR_5-1742095998822.png

 

Test results

ChaitanyaILCR_6-1742096068270.png

 

ChaitanyaILCR_7-1742096106519.pngChaitanyaILCR_8-1742096136619.png

ChaitanyaILCR_9-1742096160609.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

 

Vasu2
Tera Contributor

Hi @Chaitanya ILCR 
Can you help on this scenario where there are multiple Incidents are there and each incident will have Multiple Approvers. The description string format is {"Rank 1": ["user_id1"], "Rank 6":["user_id2"]}. We do not have to sent the approval if the string contains "Rank 25" and above Rank like "Rank 26". We have to send the Approval for only the userIDs which has the rank below 25. We need to send the Approvals for all the incidents at a time, If there are multiple Approvals for a Incident, anyone can Approve or Reject. If anyone Approves the rest of Approvals for that Incident is not required.
Thanks,
Vasu


Hi @Vasu2 ,

Update the set flow variables flow logic's script with below and try

var res = [];
var desc = fd_data.trigger.current.description.toString(); 
//assuming the record is the trigger and field is description feel free to update them 
//test string '{"Rank 1":["Hello"],"Rank 2":["fjalf"],"Rank 3":["fadfa"],"Rank 25":["080"],"Rank 26":["26"]}'
desc = JSON.parse(desc);
for (i in desc) {

    var tempAr = i.split(' ');
    if (tempAr.length > 1) {
        var index1 = tempAr[1];
        var index1Int = parseInt(index1);
        if (index1 && !isNaN(index1Int) && index1Int < 25) {
            res = res.concat(desc[i]);
        }
    }
}
return res.join();

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Vasu2
Tera Contributor

Hi @Chaitanya ILCR ,

The description is not there on the catalog form, only the incident number is available in the list collector field. we need to send the approval for all incident approvers at a time. The approvers for each Incident are in description field of that Incident.

Thanks in Advance