- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 05:31 AM
We have a situation in a Flow where a user can select multiple softwares from a request form. We then want to show all those selections in the Description field of a Catalog Task in that Flow. The issue is, if you drag the data pill of the List Collector Variable into the text of the Description field, it shows you the sys_ids of the selections, separated by commas, and not the display names of those softwares. So I need to convert this list of sys_ids to a list of display names.
I am thinking this could be a handy thing to make a generic Custom Action, as I could see this functionality being re-used in other Flows too. My thought is to create a Custom Action that iterates through the selections in a Glide Record, looks up the display value, and writes a comma-separated string of the display value. I have not done that yet, but I think that I should be able to do all of that.
My question is this: is there some way in my script for this Custom Action to identify the Reference table the List Collector is coming from? If not, I will need to include the table name as an Input for my Custom Action. But I was thinking, there should be a way to figure it out from the List Collector variable itself. I am just not sure how.
And I am not quite sure if I need to specify the field name I want to return, or if I can just use GetDisplayValue.
Basically, I am just trying to figure out if there is a way that instead of having these three Inputs for this Custom action:
1. List Collector Variable value
2. Reference Table
3. Field to Return
to just have:
1. List Collector Variable value
and derive the second two from the first.
Or am I asking too much?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:27 AM
I got it! What you said gave me a clue, when you said that the Input Value is a Glide Record. I should just be able to iterate through that and grab the display values.
So, I just have this one input now (which is my List Collector):
And this script:
(function execute(inputs, outputs) {
var str = '';
//loop through list collector (Glide Record)
var gr2 = inputs.lc_variable;
while(gr2.next()){
//get Display Value of record
str += gr2.getDisplayValue() + ',';
}
//remove last comma from string
str = str.substring(0, str.length-1);
//set string to output
outputs.output_string = str;
})(inputs, outputs);
and it returns exactly what I want!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 07:28 AM
List Collector variable type is 'List' not string, so it will be passing GlideRecords not string of sys_ids, so before passing to the custom action, you should turn that into a string of sys_ids.
Even if you change your custom action input type to 'List' you should specify 'list of which table'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:00 AM
Hmmm, that kind of defeats the purpose of what I am trying to accomplish here. The goal is to provide a Custom Action where they just enter in the List Collector field (and maybe Table and Field) name, and the Custom Action returns the a String of the friendly values. If they have to do "pre-work" to prepare the values to be fed into the Custom Action, it kind of defeats that point of having a Custom Action in the first place. I really want to do all the work in the Custom Action, so it is not left to the person creating the flow to do it. Is that possible?
I don't think I can use "List" as the type for the Input Variable, as that requires you to select the specific Table, and since I want to make a generic/reusable Custom Action, I want it to work for any table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:27 AM
I got it! What you said gave me a clue, when you said that the Input Value is a Glide Record. I should just be able to iterate through that and grab the display values.
So, I just have this one input now (which is my List Collector):
And this script:
(function execute(inputs, outputs) {
var str = '';
//loop through list collector (Glide Record)
var gr2 = inputs.lc_variable;
while(gr2.next()){
//get Display Value of record
str += gr2.getDisplayValue() + ',';
}
//remove last comma from string
str = str.substring(0, str.length-1);
//set string to output
outputs.output_string = str;
})(inputs, outputs);
and it returns exactly what I want!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 05:56 AM
Hi @jmiskey , That's actually a good use case. 😃
I found a script in the community(you might have already seen it) - Solved: How to find record name and table name with sys_id... - ServiceNow Community
When I tried it, it took some time to get the results because it queries all the tables. You can limit the tables if needed.
Adding the TableName and FieldName to return would help reduce the querying time.