Notification on custom table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 03:20 AM
Hello All,
I want to set up notification on custom table which have the RITM number , Change request and Change task , Requested for this all are string field , so when the record in custom table status mark as failed , i need to trigger a mail to Requested For , Now here requested for is a string field which holds the user id .
I am not getting how to bring this requested for in CC as this is a string filed we need to populate the email with respect to User ID present in Requested For field and this requested for should come like Dear ${Requester}
Please help on this.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 03:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 03:42 AM
Hello Sandeep,
this notification is on custom table which have string field this field are not reference field Requested For is string field which have user Id .So how to use that in adding the address
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 03:45 AM
Hi @Nisha B ,
Hope you are doing great.
To set up notifications on a custom table in ServiceNow for IT asset management, follow these steps:
- Create a new Business Rule that triggers when the record status on the custom table is marked as "failed."
// Business Rule Name: NotifyOnStatusFailed
// Table: <your_custom_table>
// When: Before
// Insert true
// Update true
(function executeRule(current, previous /*, g*/) {
if (current.status == 'failed') {
var requestedFor = current.requested_for; // Assuming "requested_for" is the field holding the User ID
if (requestedFor) {
// Get the user's email using the user ID from the "requested_for" field
var user = new GlideRecord('sys_user');
if (user.get('user_name', requestedFor)) {
var email = user.email;
if (email) {
// Send the email notification
var subject = 'Notification: Record Status Failed';
var body = 'Dear ' + requestedFor + ',\n\nThe status of your record on the custom table has been marked as failed.';
gs.eventQueue('email.send', current, email, '', subject, body);
}
}
}
}
})(current, previous);
send the notification - who will receive or set it via notification email script.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2023 04:00 AM
Hi @Nisha B
Create Email Script for the notification and in that email script write code like below and try.
var requestedFor=current.u_requested_for;
var grUser=new GlideRecord('sys_user');
grUser.addQuery('name',requestedFor);//if sysid is in Requestedfor field then use grUser.addQuery('sys_id',requestedFor);
grUser.query();
if(grUser.next())
{
email.addAddress("cc",grUser.email,grUser.name);
}
Please refer the below link.
https://www.servicenow.com/community/now-platform-forum/how-to-set-cc-with-email-content/m-p/1025103
Please mark my answer as helpful and correct if it helps you.
Regards,
Namrata