How to set a flow variable of type array using a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi,
I am using a flow for a catalog item, where there is a variable which contains an object which has an array.
And I need to generate approvals dynamically based on the length of the array.
So I though of creating a flow variable of array type and using set flow variable I will be able to parse that variable and set the variable with the array, but I do not see any option of wrting a script. The option appears for string type of variable. Any pointers will be appreciated thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Suvro,
You might have to create a custom action to make this work.
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @suvro
May you use a List Collector in the Catalog Item and a For Each in the Flow.
This is the best and recommended approach.
Catalog Item
Create the variable as:
- Type: List Collector
- Reference: the appropriate approval table
A List Collector already returns a list of sys_ids, which Flow Designer treats as an Array.
Flow Designer
- Use the catalog variable directly
- Add a For Each action
- Iterate over the List Collector values
- Inside the loop, use Create Approval
- Approver = current item from the loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
check this for scripted flow approval
Scripted Approvals in Flow Designer with Flow Variables
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
