Push values into array using Lookup records in Flow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 08:13 PM
Hi,
I'm trying to look up resource plan records and push all the Group managers of those resource plans into an array.
How is this possible in the flow designer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 12:51 PM
Here is one way that you can do it using a Flow Action to contain the script. You should also be able to do it by using a script to set a flow variable and looping through the fd_data object, but I haven't been able to get it to work that way yet.
Here's an excerpt from a flow
It creates a lookup records collection and then loops through it and calls the custom action to add the RP Manager sys_id to the array. The array is represented as a comma-delimited Flow Variable string since Flow does not support arrays as a data type.
Then in the Set Flow Variable action, it sets the Flow Variable string to the output of the action:
The custom action simply has two inputs - a reference to User and an optional starting array string:
It then has a script step:
And a single output, which is set to the output of the script step:
Please mark as Helpful/Correct if this helped to resolve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 05:45 AM
Forgot to deduplicate the results. Replace the script in the flow action with this:
(function execute(inputs, outputs) {
// ... code ...
var arIDs = [];
if (inputs.startingarray) {
arIDs=inputs.startingarray.split(',');
arIDs.push(inputs.rpmanager);
var arrayUtil = new ArrayUtil();
outputs.endingarray=arrayUtil.unique(arIDs).toString();
}
else {
outputs.endingarray=inputs.rpmanager;
}
})(inputs, outputs);