- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 09:48 AM
Hi,
I have a request to create a notification email when the wizard is submited to update the CR. I need to figureout how to create the event to trigger the notification (which I need to figure out how to create) and also how to call the event in a client script.
Please Help! 🙂
Thanksin advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 12:26 PM - edited 11-08-2023 12:28 PM
When using an event to trigger a notification, you'll need to create the event in the event registry: Event Registry | ServiceNow Developers
You can call the event almost anything you want...but some event names are reserved, though not registered in the registry. Most are in the format of "tableName.action" (like "sc_req_item.updated" <- reserved) -- have a look at a post I made, when I ran into this trouble: Solved: Event registry issues/inquiry - ServiceNow Community ...but I would recommend sticking with that naming convention -- perhaps "change_request.wizard.notification"
Once you have the event registered, you will need to call it from the client script (as you know)...I am not familiar with the wizard, but if all you need is the code to call the event, it will look like this:
gs.eventQueue('change_request.wizard.notification', current, PARM1, PARM2);
...where "PARM1" and "PARM2" are variables that you can use to pass parameters (usually recipients for the notification email) to the email notification. Here is a link that describes the event creation, when you use the code above to add the event to the event queue ("calling the event"): Generating Events | ServiceNow Developers
From here, you just need to create a notification that sends/triggers when the event is called/fired, which is the easiest part. Go to the Email Notifications table and create a new one, set it to "Event is fired" on the "When to send" tab and select the event you registered previously. You will either need to pass the recipient as a parameter, when the event is called (as described above) or you will be able to access it directly (if static, perhaps) on the "Who will receive" tab.
Here is some documentation that describes the email notification creation: Create an email notification (servicenow.com) and some more about triggering the notification (via event queue): When to Send | ServiceNow Developers
Hope this helps, best of luck!! 😁
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 12:26 PM - edited 11-08-2023 12:28 PM
When using an event to trigger a notification, you'll need to create the event in the event registry: Event Registry | ServiceNow Developers
You can call the event almost anything you want...but some event names are reserved, though not registered in the registry. Most are in the format of "tableName.action" (like "sc_req_item.updated" <- reserved) -- have a look at a post I made, when I ran into this trouble: Solved: Event registry issues/inquiry - ServiceNow Community ...but I would recommend sticking with that naming convention -- perhaps "change_request.wizard.notification"
Once you have the event registered, you will need to call it from the client script (as you know)...I am not familiar with the wizard, but if all you need is the code to call the event, it will look like this:
gs.eventQueue('change_request.wizard.notification', current, PARM1, PARM2);
...where "PARM1" and "PARM2" are variables that you can use to pass parameters (usually recipients for the notification email) to the email notification. Here is a link that describes the event creation, when you use the code above to add the event to the event queue ("calling the event"): Generating Events | ServiceNow Developers
From here, you just need to create a notification that sends/triggers when the event is called/fired, which is the easiest part. Go to the Email Notifications table and create a new one, set it to "Event is fired" on the "When to send" tab and select the event you registered previously. You will either need to pass the recipient as a parameter, when the event is called (as described above) or you will be able to access it directly (if static, perhaps) on the "Who will receive" tab.
Here is some documentation that describes the email notification creation: Create an email notification (servicenow.com) and some more about triggering the notification (via event queue): When to Send | ServiceNow Developers
Hope this helps, best of luck!! 😁