Email Notification should trigger to watch list aside from Business user.

Mad3
Tera Expert

Hello Community!

 

Notification should trigger to watch list, when any user aside from business user is added to the Watchlist of the ticket.


[ Any user aside from business user is added to the Watchlist of the ticket,

When, the Process State of a ticket is changed,

Then, notifications should trigger to watcher. ]

 

 --> The email body should have sentence like, State changed from Old to New.

 

---> In email body I want to give button to view the ticket in portal, is based on roles (ex:- business_user role should view the ticket only in portal)

---> one more button to view the ticket in snow based on roles  (back end those are ex:- pvis_user role, Its_admin role and ex_user role)

 

As remaining email body is same Here I don't want to have two buttons on email body, based on who is triggering the notification the link button also should populate dynamically.

 

Note: For Portal View and Snow buttons are already configured.

3 REPLIES 3

Ratnakar7
Mega Sage
Mega Sage

Hi @Mad3 ,

 

You can create a new notification in ServiceNow using the Notification [sys_notification] table. Here are the steps to create the notification:

  1. Go to System Definition > Notifications > Notifications.

  2. Click New.

  3. Fill out the fields:

    • Name: Enter a name for the notification.
    • Active: Select the check box to activate the notification.
    • Type: Select the appropriate notification type. For example, Email.
    • Recipients: Select Watchlist.
    • Condition: Enter a condition to check if any user aside from business user is added to the watchlist of the ticket. For example, current.u_watch_list_changes == true && current.u_business_user_changes == false.
    • Message: Enter the email message with the required dynamic variables. For example, "State changed from {{current.state.changes.from}} to {{current.state.changes.to}}". Also, add the buttons for viewing the ticket in the portal and ServiceNow with the dynamic links based on the user roles.
  4. Save the notification.

  5. Test the notification by adding a user to the watchlist of the ticket and changing the process state. The notification should trigger with the required message and buttons.

 

Thanks,

Ratnakar

Hi @Ratnakar7 ,

 

Thanks for the reply to triggering notification!

 

Can you explain to have buttons on email body,

I want to have two type of buttons on email notification body, when  users click on button to view the ticket in Portal and one is to view the ticket in Snow [Back end]. 

 

Based on user role the button should populate dynamically.

 

As all the users won't have access to Snow, they have access only to portal. Soo users who receive the notification should have button to view the ticket in Portal and to view the ticket in Snow.

Here same Notification will be having two buttons, based on who receive the notification and based on his role the type of button should populate in email body.

Ex:- 1. If users have business_user Role the notification email body should have button to view in Portal only with remaining email body same.

 2. If users have x_snow Role, the notification email body should have button to view in Snow only with same email body.

 

Soo here the Button link will be change in the back ground, based users role the button will display dynamically when notification is triggered. 

 

Note:- We don't want to have two notifications to have two type of buttons on email body.

 

Here when users click on button they will redirected to Snow to see the ticket.

Mad3_0-1682928916138.png

 

Here when users click on button they will redirected to Portal to see the ticket.

Mad3_1-1682928953328.png

 

Thanks in advance.

 

 

 

 

 

Hi @Mad3 ,

 

To add dynamic buttons to the email notification body in ServiceNow, you can use the HTML template in the Message field of the notification. Here are the steps to add dynamic buttons based on user roles:

->> Edit the Message field of the notification and add the required HTML template with dynamic variables.

->> Use the following code to add the dynamic buttons based on user roles:

 

 

<button id="view-portal" {{#if currentUser.hasRole('business_user')}} href="{{portal_link}}" {{else}} style="display:none" {{/if}}>View in Portal</button>
<button id="view-snow" {{#if currentUser.hasRole('x_snow')}} href="{{snow_link}}" {{else}} style="display:none" {{/if}}>View in Snow</button>

 

 

 

->> Replace the {{portal_link}} and {{snow_link}} with the actual links for the portal and ServiceNow based on user roles.

->> Save the notification.


You can also refer OOB approval email template, and build your button URL with appropriate sysparm values, like below in highlighted:

Ratnakar7_0-1682930569832.png

 

 

Thanks,

Ratnakar