provider notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 03:00 AM
how can i get state filed label instead of backend value in provider notification.i tried with email script with that notification only not triggering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 03:52 AM
In ServiceNow, when you want to get the label (display value) of a choice field like 'state' instead of its backend value, you can use the getDisplayValue() function in a server-side script.
To use this function in a provider notification, you can create an Email Script and then include it in your notification.
Here's an example of how to do this:
- Navigate to System Notification > Email > Email Scripts.
- Click on the New button to create a new Email Script.
- Enter a Name and a unique Script ID for your script.
- In the Script field, enter the following script to get the display value of the 'state' field:
(function runMailScript(current, template, email, email_action, event) {
// Get the display value of the state field
var stateDisplayValue = current.state.getDisplayValue();
// Set the variable 'state_label' that will be used in the email notification
template.print("state_label", stateDisplayValue);
})(current, template, email, email_action, event);- Click on the Submit button to save your Email Script.
Now that you've created the Email Script, you'll need to include it in your notification:
- Navigate to System Notification > Email > Notifications.
- Open the notification you want to edit or create a new one.
- In the Message HTML field, insert the variable you defined in the Email Script using ${state_label} at the position where you want to display the state label. For example:
<p>The current state of the incident is: ${state_label}</p>- n the Advanced tab of the notification, add the Email Script you created by selecting it from the Email Scripts list.
- Click on the Update or Submit button to save your changes.
Now, when the notification is triggered, it should display the state label instead of the backend value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 04:12 AM
Thanks Daniel
But its not Email notification its provider notification when i am calling email notification notification is not triggering.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 09:46 AM
is it called by event or condition?