Display value of catalogue variable in Flow Designer: a simple solution

Flavio4
Kilo Sage
Unfortunately in general* it is not possible to get the display value of catalogue variables in Flow Designer in a "no code" way.
 
Some workarounds are available in the Community and in Support (e.g. KB0960074). As far as I could find, they are either not explicit or over complicated and I spent some time in finding out this simple workaround for not very experienced users.

1. Requirements and conditions
-------------------------------------

You have a " Get Catalog Variables" action for that ("Choice") catalogue variable and you want to use the display value of it, typically in an Update Record action.

2. Issue
---------
If you use the pill from the Get Catalog Variables, only the value corresponding to the choice of the user for that catalogue variable will be returned.
You need, though, the text corresponding to the selection by the user.

3. Simple solution
---------------------

3.1 Instead of dragging and dropping the pill, click the "Toggle scripting on for ..." button for the field where you would drop the pill.

3.2 After the default/standard commented lines (usually 7), add the following:

               return
fd_data.trigger.current.variables.<variable name>.getDisplayValue();

replacing <variable name> by the name of the catalogue variable in the Get Catalog Variables.

That's it, save and activate as usual. 

3.3 If you need to concatenate, do it simply with the "+" notation, e.g.:

                return fd_data.trigger.current.variables.<variable name>.getDisplayValue() + ' in ' + fd_data.trigger.current.variables.<other variable name in Get Catalogue Variables>;

Hope it helps
Flavio4

* Reference type variables can be "dot walked" and this issue does not apply to them.
2 REPLIES 2

Ghulam Gose Ala
Tera Contributor

Hi Flavio4,

 

I just tried this answer it throws an error.

just one small change and it will work fine.

 

When we are writing "return fd_data.trigger.current.variables.<variable name>.getDisplayValue();" in code, we need to replace "current" with "request_item" and it works fine.

My updated line of script was "return fd_data.trigger.request_item.variables.<variable name>.getDisplayValue(); "

 

Everything else is spot on, thank you for sharing this.

 

 

@Flavio4  @Ghulam Gose Ala Yes agreed, "return fd_data.trigger.request_item.variables.<variable name>.getDisplayValue(); " works perfectly. Thanks to you both.

 

Was trying to build a short description from info entered on a Corporate Event form and this was the final version that worked perfectly, for future visitors.

 

//Get display values
var eventName = fd_data.trigger.request_item.variables.event_name;
var eventDate = fd_data.trigger.request_item.variables.date.getDisplayValue();
var startTime = fd_data.trigger.request_item.variables.start_time.getDisplayValue();
var endTime = fd_data.trigger.request_item.variables.end_time.getDisplayValue();

// Build the short description
var shortDesc = eventName + " - " + eventDate + " (" + startTime + " - " + endTime + ")";

// Return the short description
return shortDesc;