How to use a Flow Designer Action "Records" input in action script?

perkinsarm
Mega Guru

Flow Designer Actions have an input variable option of type Records.

I am new to Flow Designer but am experienced with workflows and scripting.  I would like to create an Action that given one or more User [sys_user] records iterates over those records and outputs a delimited string of user email addresses.

Input definition:find_real_file.png

In the script step how do I loop through the User Records so that I can build the list and output it?find_real_file.png

 

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

The Records.[table] data type is affectively a usable glide record query so you can use the below to loop over it.

(function execute(inputs, outputs) {

  var users = inputs.users;
  var emails = [];
  while(users.next()){
   emails.push(users.getValue('email'));
       }
  
  outputs.email_addresses = emails.join();
})(inputs, outputs);

find_real_file.png

find_real_file.png

View solution in original post

7 REPLIES 7

spooky!

It is actually dangerous to use this type of input variable. The thing is that after the step ran, the input variable is no longer in the same state (before, the Cursor is before the first record, afterwards it is after the last record).

This kind of side-effect leads to errors that are very hard to debug.

Therefore, I think it is better (but less efficient) to pass sys_ids or lists of sys_ids and perform an explicit query in the function.

 

Best
Daniel


If this answer was helpful, I would appreciate if you marked it as such - thanks!

Best
Daniel

Anshu_Anand_
Kilo Sage
Kilo Sage

how to test the action when clicked on test a field , its empty field for record.<table>

find_real_file.png

Regards,
Anshu