
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 09:48 AM
Hi everyone. Will try to keep this succinct.
Context: Service Catalog Flow > Create Catalog Task > Short Description > script >
I need to get the display value of a select box variable choice to help populate short description. I cannot get this value. I have tried "getDisplayValue" and "getLabel" functions and both return "undefined".
NOTE: I have looked in community but only find answers for what is apparently old functionality in Flow scripts, e.g., "fd_data.trigger.current.variables..." etc., but that no longer works because "variables" is not an option any longer from the trigger record. We therefore are using "fd_data._1__get_catalog_variables..." instead.
This is the non-functional script:
var sfuser = fd_data._1__get_catalog_variables.shop_floor_user;
var removeAllOrSome = fd_data._1__get_catalog_variables.remove_all_or_some.getDisplayValue();
gs.info(removeAllOrSome);
var sdesc = sfuser ? "Remove access - Mobile Device Login Only" : "Remove ERP access - " + removeAllOrSome;
return sdesc;
Please advise if you know how to do this; thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 10:51 AM
Somehow my search skills kicked in and I was able to find this:
That basically says you can't get display values for select box choices in Flow designer and you have to look them up in the script, so that's what I did. Here is the updated script, which works fine:
var sfuser = fd_data._1__get_catalog_variables.shop_floor_user;
var removeAllOrSome = fd_data._1__get_catalog_variables.remove_all_or_some;
/*
Next, we have to use glide record query to Look up the display value for the selected 'remove_all_or_some' choice
Ref: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0960074
*/
var qc = new GlideRecord('question_choice');
qc.addQuery('question','a7509b79db10589005c96ce2ca961997');
qc.addQuery('value',removeAllOrSome);
qc.query();
if (qc.next()) {removeAllOrSome = qc.text;}
var sdesc = sfuser ? "Remove access - Mobile Device Login Only" : "Remove ERP access - " + removeAllOrSome;
return sdesc;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 10:51 AM
Somehow my search skills kicked in and I was able to find this:
That basically says you can't get display values for select box choices in Flow designer and you have to look them up in the script, so that's what I did. Here is the updated script, which works fine:
var sfuser = fd_data._1__get_catalog_variables.shop_floor_user;
var removeAllOrSome = fd_data._1__get_catalog_variables.remove_all_or_some;
/*
Next, we have to use glide record query to Look up the display value for the selected 'remove_all_or_some' choice
Ref: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0960074
*/
var qc = new GlideRecord('question_choice');
qc.addQuery('question','a7509b79db10589005c96ce2ca961997');
qc.addQuery('value',removeAllOrSome);
qc.query();
if (qc.next()) {removeAllOrSome = qc.text;}
var sdesc = sfuser ? "Remove access - Mobile Device Login Only" : "Remove ERP access - " + removeAllOrSome;
return sdesc;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 08:10 AM
Hi @apjohn2 ,
I had the same problem, thanks for pointing to the KB article.
I solved it differently, by using the getDisplayValue() function of the RITM/SC Task. Maybe interesting for others that read this post.
I created a flow action, with the RITM and Task as input + the question/variable.
var grTask = !gs.nil(inputs['ritm']) ? inputs['ritm'] : inputs['sc_task'];
if(!gs.nil(grTask)){
var variableName = 'variables.' + inputs['variable_name'];
outputs['displayvalue'] = grTask.getDisplayValue(variableName);
}
This makes it generic, so you can re-use it in every flow.
Regards,
Hayo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 02:42 PM
Hi Hayo,
I'm having trouble replicating what you did - do you mind sharing the details of the action you created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 08:55 AM
Hello,
Were you able to get the answer to this?
Thanks,
Chad