ServiceNow Flow designer to look in to a table field and send the Approvals
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2025 07:50 PM
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...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 09:48 AM
Hi @Chaitanya ILCR ,
I used Look Up Records and it worked. In the below script, If the short description contains Index values both less than 25 and greater than 25 combined and also some short descriptions contains only less than 25. how to send the approvals for all the users having less than 25 index value and remove the approvals for Index greater than 25 and add a default user ID say "abcd" if the short description contains indexs greater than 25 along with the userIDs with indexes less than 25.
I am trying to achieve the functionality if the short description contains both the indexs greater than and less than 25, in this case we need to send the approval for the userIDs less than 25 and also to a default user. If the short description contains only indexes less than 25 then we no need to send the approval for the default user.
Can you help me with this Logic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 06:11 PM
Hi @Chaitanya ILCR ,
I got the output correctly till the Setting flow variables, but in the lookup record it is only sending one record not all the records. I saw in my flow designer, for Look up record, I saw If multiple records are found send only the first record, may be I am thinking that might be the cause, I did not saw that option in you screenshot, Please let me know in detail how you achieve the below Look up record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 09:49 AM
Hi @Chaitanya ILCR ,
I used Look Up Records and it worked. In the below script, If the short description contains Index values both less than 25 and greater than 25 combined and also some short descriptions contains only less than 25. how to send the approvals for all the users having less than 25 index value and remove the approvals for Index greater than 25 and add a default user ID say "abcd" if the short description contains indexs greater than 25 along with the userIDs with indexes less than 25.
I am trying to achieve the functionality if the short description contains both the indexs greater than and less than 25, in this case we need to send the approval for the userIDs less than 25 and also to a default user. If the short description contains only indexes less than 25 then we no need to send the approval for the default user.
Can you help me with this Logic
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 07:33 PM
Hi @Vasu2 ,
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 temp = parseInt(i.slice('5'))
if (temp && !isNaN(temp) && temp < 25) {
res = res.concat(desc[i]);
} else {
var defalutUserID = 'admin'; /*update the default user id here*/
if (res.indexOf(defalutUserID) == -1)
res.push(defalutUserID )
}
}
return res.join()
use this
I went through your requirement and tried created a test catalog item with one list variable which references incident table and a flow
i have even added test incident I have used to the update set
import this update set into your PDI and work on it
only thing is I couldn't add logic that generates all the approvals at once
this flow only triggers approval for one incident at a time
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya