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

sachin_namjoshi
Kilo Patron
Kilo Patron

You can use For Each Logic to loop through records in flow designer.

 

Regards,

Sachin

Sachin,

I'm aware of that. I first tried that in the flow that I want to call this action from, but Flow Designer doesn't provide variables that would allow me to build the list of email addresses I need.

When I first started developing my Action, I looked for a For Each step option. Actions don't offer Flow logic, except within a script. (I am working on Orlando).

My question is how do I work with the type Records input in a flow Action script. I'm assuming that my script will iterate over each record. 

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

Thanks @Kieran Anson ,

I actually figured that out while you were responding.  My working script was identical to yours.

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