The requirement
My first project as a ServiceNow developer was to implement a solution that would allow admins to send a welcome email to users that informs them how to log into the instance, what their username is and what groups they are a part of. This will save valuable time for admins and hopefully reduce support tickets.
How this was achieved
I decided to implement a welcome email system in ServiceNow by utilising three components, the first was a UI Action on the sys_user form to allow admins to press a button and send the Welcome Email. The button then fired an Event with the users information that a Notification can be triggered from. I then ensured the button was locked down so only Admin users could see this. Continue reading below to see the code behind each step.
The Code Involved
UI Action
The UI action is based on the sys_user table and utilises a Form Button, it provides an info message of confirmation for the admin and sends the username and sys_id of the current user record into the event.
1 2 3 | gs.addInfoMessage('Welcome email notification has been generated!'); action.setRedirectURL(current); gs.eventQueue("event.name", current, current.sys_id, current.user_name); |
Event
The event is added to the event registry and created on the sys_user table.
Notification
A notification on the sys_user table is then created that will send when the event listed above fires. As the end user is listed in the Parm 1 of the event I can select this on the “Who will receive” tab. Finally I can add some content in the form of a template and attach this template to the “What will it contain” section on the notification. Something similar to the code below was used:
1 2 3 4 5 6 7 8 | Welcome to ServiceNow ${first_name} your username is ${user_name}. You can login using the following link. You are in the following group: ${group} Working for: ${department} Thanks ServiceNow team |
Conclusion
This was a great first project to work on, it allowed me to get to grips with firing notifications from events, dynamic content in email templates and also a small introduction to simple UI actions.
#
Hello Dan
I found this post and I am interested to know what would happen if the users are assigned to multiple groups, will it fire off the email displaying all groups?
Thanks