Flow Designer For Each loop using GlideAggregate issues

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2020 05:12 PM
I built a workflow using Flow Designer. I ran into an issue when I implemented a For Each loop on an object returned by a Script Action. The For Each iterates through the list of records, but I cannot pull any field values from any of the records in the loop. Does For Each only work with GlideRecord? I know GlideAggregate extends GlideRecord, so I'm not sure why this wouldn't work.
This first screenshot shows the version against a GlideAggregate object. Note the "Activity Designs" output data shows "View All", which is circled in red. The second screenshot shows the version against the GlideRecord object. Its "Activity Designs" output data lists the Sys Ids of each returned record.
The second issue is with the "If" statement. The first "Condition" value I believe should show the "Order" field value. I circled the blank value in red. Compare this to the second screenshot to see that the GlideRecord does return a value.
If anyone has had success with using a GlideAggregate in a For Each block, please let me know. I'm hoping this is my error and not a limitation of the platform.
For Each on GlideAggregate:
For Each on GlideRecord:
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2020 07:52 PM
Hi Erik -
As mentioned in the servicenow docs, the GlideAggregate is expected to return a single value or count of records (based on the aggregate function that you use). I don't think you can loop on the result similar to GlideRecord which will hold the details of each result record.
**Mark this response as Correct Answer/Helpful, if this has helped you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 09:40 AM
I'm pretty sure you can based on the Group By value. I was grouping on "Order", and I'm pretty sure I could loop through the distinct Order values. I believe I tested this. Also, if you look at my screenshot of the For Each above, you can see that it has multiple records to iterate through.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 03:08 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2020 01:40 PM
I don't think returning an array of strings will work because the For Each in Flow Designer only works against GlideRecord.