Flow Action returning sys_id for list collector variables

ar1
Kilo Sage

Hi All and @Ankur Bawiskar 
Can anyone please help on the below issue.

We have a catalog item with List Collector variables and Based on the List collector variable selection we need to create the SCTASK tickets.

And so far everything is working fine but during the flow action output level we're seeing the list collector selected options sys_id's 

 

ar1_1-1691082245347.jpeg

 

 



But we want display the selected options names.

Below flow action we created and called on flow level and both input and output types are array.string.

We gave a try changing the type array, object and array.object but no luck.

 

ar1_0-1691082020026.png

 

Note: below thread helps us to create the Action.

https://www.servicenow.com/community/developer-blog/using-list-collector-in-flow-designer-for-each-l...



Advance thanks.

11 REPLIES 11

Ankur Bawiskar
Tera Patron

@ar1 

why not query that table with the sysIds and store the display value in array and then return it

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,
Thanks for the response, Apologies for the last response

Could you pls share the sample script to display the names instead of sys_id'S.

Note: Is there any way we can use one "Action" for future list collector variable's requirement.
I mean  currently the existing List collector variable referred to "cmdb_ci" table but in future there may chance to create multiple List collector variables for different catalog items.
So that we can use the existing action  without modifying the script on action level.

Advance thanks.

@ar1 

then to make it re-usable ensure you pass these 2 inputs to that action

1) table name being referred by list collector

2) sysIds

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,
You're saying that we need to create two inputs
1. TableName and Type is List collector
2. SysID and Type is String

Sorry we got confused.

as you mentioned we query the cmdb_ci table level on script level, but we need to re-use the action for future requirement.

(function execute(inputs, outputs) {

function getCiName(sysid) {
var gr= new GlideRecord('cmdb_ci');
gr.get(sysid);
return gr.name;
}

var ids= [];
var lstr = inputs.variable.toString().split(',');
for (var i = 0; i < lstr .length; i++) {
lcd.push(getCiName(lstr [i]));
};

outputs.variable = ids.toString().split(',');

})(inputs, outputs);


Advance thanks.