- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 02:57 AM
Hello,
Currently within any items using a flow, the short description fields are populated with text and then data pill for a form choice such as hardware type. However, when the short description is populated, it is the value of the choice and not the display value.
I've had a look through some of the transforms and scripts but can't see a way to get the display value to show instead - can someone tell me how to achieve this?
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 4,638 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 06:05 AM
I was able to get the variable choice label and set it in Task Short Description; please try this
Script for your case:
var ritmSysId = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);
var variableDisplayValue = rec.variables.please_select_the_type_of_change_you_require.getDisplayValue();
return 'New Work Request - ServiceNow:' + variableDisplayValue;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 05:45 AM
This seems to work until the variable displayvalue retrieval - it is giving 'undefined', I tried to remove .variables. from the script but this didn't work either
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 06:05 AM
I was able to get the variable choice label and set it in Task Short Description; please try this
Script for your case:
var ritmSysId = fd_data.trigger.request_item.sys_id;
var rec = new GlideRecord('sc_req_item');
rec.get(ritmSysId);
var variableDisplayValue = rec.variables.please_select_the_type_of_change_you_require.getDisplayValue();
return 'New Work Request - ServiceNow:' + variableDisplayValue;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 06:16 AM
That's it working now, thanks a lot man!
Also works for populating the request short description too 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 07:30 AM
Glad that it worked.
Please remember to mark my response as correct and helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 07:28 AM
Hope you are doing good.
Please remember to mark my response as correct and helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader