For Each Item flow logic how to get the consolidated output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 08:03 PM
while creating a record I need to get related list of records and perform a REST action for each record . I'm using this flow and its working fine however I've no idea how we can get the final output to a variable.
Basically each REST response will return an unique reference and I wanted to update the concatenate value of response to a field in the table.
jamsheer
- Labels:
-
flow designer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 08:10 PM
Had a similar situation.
One way is to update the table in each iteration.
The other way that I took was to move the for loop into a Script step in Custom Action. Instead of using Flow's REST call, I copy & pasted REST script generated by creating a REST Message.
https://docs.servicenow.com/bundle/orlando-application-development/page/integrate/outbound-rest/task/t_ConfiguringARESTMessage.html

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 08:28 PM
Hi Jamsheer,
You can try the below. I assume that you are going to update the short description field of change. create a output to the flow only for the rest value. create a step below the Rest call to update the record and try this script in the short description. Amend the 2nd line.
var nowShortDesc = ParseInt(fd_data.current.short_description);
var addShortDesc = ParseInt(fd_data._rest_step.valueid);
return nowShortDesc+addShortDesc;
If you like to go without script, then you can add lookup record to search that record and concatenate the value like below. step 5 is lookup and step 6 is to update the short description.
short description = Lookup record's short descrption + rest message output; [I dont have rest step here so I pulled step 4 short description]
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2020 04:25 PM
Thank you Murali, I was able to get the results based on your input however I was looking for a solution which doesn't update the target record multiple times. Let's say if the CI list has 100 records then the CHG record get's updated 100x which may not be a good idea .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2020 01:22 AM