provider notification

Soujanya Dudduk
Tera Contributor

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.  

3 REPLIES 3

Daniel Biesiada
Mega Guru

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:

  1. Navigate to System Notification > Email > Email Scripts.
  2. Click on the New button to create a new Email Script.
  3. Enter a Name and a unique Script ID for your script.
  4. 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);
    1. 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:

    1. Navigate to System Notification > Email > Notifications.
    2. Open the notification you want to edit or create a new one.
    3. 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>
      1. n the Advanced tab of the notification, add the Email Script you created by selecting it from the Email Scripts list.
      2. 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.






Thanks Daniel

 

But its not Email notification its provider notification when i am calling email notification notification is not triggering.

is it called by event or condition?