Return List of sys_user in Flow Designer Action

Kyle Cribbs
Giga Contributor

I am having an issue on how to return a list of referenced users in my flow designer action.

I have 2 inputs for querying, 1 asking for roles (array of strings), and 1 asking for the project (string) they are assigned to. I have the script look up the users and get their sys_id's for each user. This all works. 

The issue I am having is how to return the values. My output is current a "List" to sys_user and I populate that by my script variable called "users"

I have tried passing 

164ad5c6519110107f610b038645ddb3,3a98e903810d50107f612b41b4439bef

And it does not display the users.

I have tried passing

sys_IN164ad5c6519110107f610b038645ddb3,3a98e903810d50107f612b41b4439bef

This does not display the users.

I have made the output field a reference to sys_user and returned a single user of 

164ad5c6519110107f610b038645ddb3

And it displays the user Andrew Anderson

 

So how are you supposed to pass a list of sys_id's for a List Reference Output field? 

 

Here is my code for anyone wanting to see it for my Action Script Step

var gr = new GlideRecord('x_snc_authorizatio_stakeholders');
gr.addQuery("project_id.project_id", inputs.project_id);

for ( index in inputs.roles ){
  role = inputs.roles[index]
  if(index == 0){
    var rq = gr.addQuery('role.role_name', role);
  }
  else{
    rq.addOrCondition('role.role_name', role);
  }
}
  
  
gr.query();
var sys_ids = [];
while(gr.next()) {
  sys_ids.push(gr.users.sys_id);
}
    
outputs.users = sys_ids.join(",");

Here is my Output screenshots

find_real_file.png

find_real_file.png

9 REPLIES 9

Muralidharan BS
Mega Sage
Mega Sage

Hi Kyle,

If you pass on a project id in the script and try in background script, is it returning expected value?

I’m not sure I understand your question related my question above. The logic in the script is correct and returns the correct sys_ids. I’m asking “how” do I need to return this sys_ids for a list reference.

Hi Kyle,

If I understood correctly, you wanted to do add the output of sys_id to a list field type (glide_list) in a record. If so, 

change the output type to string - 

find_real_file.png

 

Add the output to the list type in the record:

find_real_file.png

 

Result:

find_real_file.png

 

Kindly mark my response correct and helpful if my suggestion resolved your query,


Thanks

Murali

 

Thanks for the reply! Sadly it needs to be a list reference because we are using it for approval. It will not accept a string.