Scripting for Email Notifications - Getting the display value of a choice list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2013 03:22 AM
I'm having trouble with getting a the display value of a choice list into my mail template. Can anyone help me with the correct syntax? You think it would be getDisplayValue() but that doesn't do it.
What I want to see in my resolved template:
Dear Customer,
We have closed your incident with the following reason:
Customer- Configuration-Polite Customer Facing Phrase-another one
What I get:
Dear customer
We have closed your incident with the following reason:
cu-conf-pcfp-anoth
Below is a mail script snipped of what I have tried for the left hand variable (close code level 1), and what it prints
template.print( current.u_close_code_l1.getLabel() + "-" // Displays the field label, Close Code L1
+ current.u_close_code_l1.getDisplayValue() + "-" // displays cu which is NOT the display value, it's the value
+ current.u_close_code_l1.getValue() + "-" // undefined
+ current.u_close_code_l1 + "-" // displays cu again
)
There's a huge choice of labels/values over four levels of close codes, with lots of repetition, so I need the database values to be distinct, hence the cu conf npp style values. So I can't just make the values and labels the same on the choice list.
So what's the magic mail script line to print the display value, not the value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2013 11:42 PM
Can you try this
gs.log(current.impact.getDisplayValue());
gs.log(current.impact.getChoiceValue());
gs.log(current.impact.getLabel());
var value = current.impact.getDisplayValue();
template.print( current.u_close_code_l1.getLabel() + "-" // Displays the field label, Close Code L1
+ current.u_close_code_l1.getDisplayValue() + "-" // displays cu which is NOT the display value, it's the value
+ value + "-" // undefined
+ current.u_close_code_l1 + "-" // displays cu again
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2013 02:34 PM
.getChoiceValue();
I just needed to figure this out from some jelly code.
http://wiki.servicenow.com/index.php?title=GlideElement#getChoiceValue.28.29
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2013 03:37 PM
Thanks for sharing Scott, I have had this same issue.