Email script are not working for some sent notification resulting it send blank info
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2025 09:23 AM
this is script this works all the time
but sometime do not print data in notification
I have checked even parameter it was passed correctly
I cannot find any result why it didn't print any data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2025 11:43 PM
Try to debug the script execution by adding more logging to see what is empty. It might be that no such record based on event parm is found, or that such a record has "u_contact_by" empty, or that record has "u_advisor_schedule" empty. I have drafted something for you, without testing it, so please review the code first. Test the code in non-prod environment, and it might help to find what is empty.
var grContact = new GlideRecord('xyz');
if (grContact.get(event.parm1)) {
if (gs.nil(grContact.u_contact_by)) {
template.print("Contact by is empty");
} else if (gs.nil(grContact.u_contact_by.u_advisor_schedule)) {
template.print("Advisor schedule is empty");
} else {
var scheduleValue = grContact.u_contact_by.u_advisor_schedule;
template.print("Schedule value: " + scheduleValue);
}
} else {
template.print("No contact found for " + event.parm1);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2025 03:12 AM
Hi Dominik,
Thank you for your reply.
This issue is only occurring in the production environment; everything is working as expected in non-production. Therefore, attempting to log in for troubleshooting purposes has not been effective.
As I am new to ServiceNow, I am not entirely sure about the root cause. Is it possible that the notification is being processed before the record is saved? The notification is triggered by an "on before", "insert" business rule, and the mail script uses the current data from the same record.
Thank you for your guidance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2025 03:23 AM
Hi Dominik,
Thank you for your reply.
This issue is only occurring in the production environment; everything is working as expected in non-production. Therefore, attempting to log in for troubleshooting purposes has not been effective.
As I am new to ServiceNow, I am not entirely sure about the root cause. Is it possible that the notification is being processed before the record is saved? The notification is triggered by an "on before insert" business rule, and the mail script uses the current data from the same record.
Thank you for your guidance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2025 02:40 AM
Did you add any logs? Where was it broke?