- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 10:52 PM
I want to extract the value of a record's choice field in a flow.
In a data pill I get the label value.
Is there a better way to do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 11:44 PM
not possible. It's a platform behavior and it will always give choice label and not choice value
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @Asha Patil,
By default, ServiceNow Flow Designer retrieves the backend Value of choice fields (e.g., 10 or new_value) rather than their user-friendly Label (e.g., New or In Progress) when you drag and drop a standard data pill.
To store the readable label instead of the backend value in a flow variable, you must use inline scripting with the getDisplayValue() method.
Here is how you can set it up in your flow:
1 - Add/Edit the "Set Flow Variables" :
- In your Flow, add or navigate to the Set Flow Variables action;
- Select your target String variable.
2 - Enable Inline Scripting, instead of dragging and dropping the field's data pill directly into the Value field:
- Click the Script icon (</> or fx) next to the variable's value field to open the inline script editor;
3 - Write the Script, use the following Javascript snippet depending on where your choice field originates:
Scenario A: Standard Choice Field on a Record (e.g., Incident State)
If your choice field is from a standard table record triggered at the beginning of the flow, use:
return fd_data.trigger.current.YOUR_FIELD_NAME.getDisplayValue();
Replace YOUR_FIELD_NAME for the technical name of your choice field.
Scenario B: Service Catalog Select Box / Choice Variable
If you are pulling a choice variable from a Service Catalog Item (RITM):
return fd_data.trigger.request_item.variables.YOUR_VARIABLE_NAME.getDisplayValue();
Replace YOUR_VARIABLE_NAME for the exact name of your catalog variable.
The platform's native data pill system evaluates choice and reference fields to their raw database values (sys_id or choice value). Writing a simple one-line script bypasses the default mapping behavior and explicitly pulls the display label.