Return Text of a Multiple Choice Field in a Flow Designer Script

jmiskey
Kilo Sage

I have a Multiple Choice Variable on a Catalog Item named "Role Selection (role_selection)", that has 3 possible values, as shown below:

jmiskey_0-1738601049391.png

 

In Flow Designer, I am trying to display the Text of this selection in the Comments of an Approval that is being created.  I am doing that with an "Update" action in my Flow, to update the Comments field on the Approval record.  I am using the "Script" option on the Comments field, and as getting the Role Selection like this:

var role = fd_data._1__get_catalog_variables.role_selection; 

 

The issue is this returns the "Value", not the display "Text".  So it returns "sourcing_manager" instead of the desired "Sourcing Manager".

 

I though maybe I could update that variable like this:

var role = fd_data._1__get_catalog_variables.role_selection.getDisplayValue(); 

but that does not work.  It returns an error, saying:

Error: Cannot find function getDisplayValue in object company_administrator.,Detail: Cannot find function getDisplayValue in object company_administrator.

 

How can I code this to return the "Text" value and not the "Value" value?

 

Thanks.

1 ACCEPTED SOLUTION

Saloni Suthar
Mega Sage
Mega Sage

Please take a look at - https://www.servicenow.com/community/developer-forum/retrieve-display-variable-value-in-flow-designe...


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

View solution in original post

2 REPLIES 2

Saloni Suthar
Mega Sage
Mega Sage

Please take a look at - https://www.servicenow.com/community/developer-forum/retrieve-display-variable-value-in-flow-designe...


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

jmiskey
Kilo Sage

Thank you!  That method worked!  I had to rewrite it as:

var role = fd_data.trigger.request_item.variables.role_selection.getDisplayValue();

and it worked!