
- 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
06-10-2024 11:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 04:01 AM
I have tried playingaround with this since I would like to return the Variable.Text and not the Variable.Value in a record producer.
As far as I can see the question Sys_id is uniq for each choice in the select box variable, which makes this very cumbersome if I have a select box with (for instance) 10 choices, which if I understand this correctly leaves me with hardcoding 10 seperate combinations of Value and Question SysIDS..
Any input or ideas on how to obtain, what I am looking for , would be much apreciated 🙂
Al I want is to be able to return the Label (of the selected choice) from a select box type variable (on a incident record producer), because I want to include the selected (Value's Label) in the description field on the incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 09:54 AM
Hello,
What inputs and outputs did you use?
Thanks,
Chad