Flow Action returning sys_id for list collector variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 10:05 AM
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
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2023 08:38 PM
why not query that table with the sysIds and store the display value in array and then return it
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 05:06 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 05:19 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 05:28 AM
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.
