- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 12:59 AM
Hi,
In flow designer, i need to query and update multiple records in a table. when using look up action, need to define the max results (if not defined it is set to 1000). i would like to dynamically define the max results by counting the number of records in the table.
Is there a flow designer action to count all records in a table or this would need to be done using a script / custom action?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 01:33 AM - edited 07-25-2023 01:34 AM
So another alternative is to use a flow variable and set this using a script:
- Define a new flow variable. This could be called anything but for the sake of clarity I will use recordCount and set it as an integer
- Create a flow action to Set Flow Variables and select your newly created variable from the list
- In the data column press the Toggle for scripting button and use the below code
var grCount = new GlideRecord('TABLENAME');
grCount.addEncodedQuery('QUERY HERE');
grCount.query();
return grCount.getRowCount();
This will query the intended table with whatever query you set to get a count. The return line then populates the flow variable recordCount with the number of records. You can then use this data pill for the Max Records on your Lookup Records query.
Hopefully that does the trick. Not had need to do this myself but this is how I would tackle it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2023 11:13 PM
Hi Tera,
Thanks for you suggestion - that option indeed work. Eventually i created an action that does something similar. By doing it with an action, I was able to reuse it in several sub flows i needed.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 05:58 AM
Brilliant - glad it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 12:54 AM
I would consider using GlideAggregate as using GlideRecord just to get the number of records with getRowCount is considered bad practice (performance)