Email notification "Event parm 1 contains recipient" not working

DoDo labs___
Mega Sage

Hi!

 

 

If I set a user in the email notification "Users", he receive the email.
However, when I use “Event parm 1 contains recipient,” that user doesn’t.
In the Message HTML, I print the value of parm 1 like this: ${event.parm1}.
The sys_id appears correctly in the email body.
I also tried sending an email address — it also shows up correctly in the body.
But only the user defined in the “Users” field receives the email; the one from parm 1 does not.

Here’s the scheduled script:

 

var userek = new GlideRecord('sys_user');
userek.addQuery('sys_id', '1a88d14a47a4dd90a7a05502e26d4327');
userek.addQuery('active', true);
userek.addQuery('locked_out',false);
userek.addNotNullQuery('ldap_server');
userek.addNotNullQuery('last_login_time');
userek.query();
while (userek.next()) {

gs.eventQueue("FIG_TEST", userek, userek.sys_id, userek.email);
}

1 ACCEPTED SOLUTION

ThoufiqA
Tera Expert

 

Here are the most common culprits for this exact situation. Let's check them one by one.

1. Check the Notification's Table

This is the most likely reason. The notification needs to know what type of record it's dealing with. Since your script is sending a user record to the event, the notification must be set up to listen for user records.

 * What to do:

   * Go to System Notification > Email > Notifications in your ServiceNow instance.

   * Open the notification that isn't working as expected.

   * At the top of the form, look for the Table field.

   * Make sure it is set to User [sys_user]. If it's on "Global" or another table, change it to "User [sys_user]" and save.

2. Make Sure "Send to event creator" is Off

There's a checkbox that can override all your dynamic settings and just send the email to the person who triggered the event (in this case, whoever is running the scheduled script).

 * What to do:

   * On the same notification record, click on the "Who will receive" tab.

   * Look for a checkbox labeled "Send to event creator".

   * Ensure this box is unchecked. If it's checked, ServiceNow ignores your parm1 recipient.

3. Do a Quick Sanity Check on the User's Profile

Sometimes, the simplest things can trip us up. Let's just make sure the user is set up to receive emails correctly.

 * What to do:

   * Find the profile of the user who should be receiving the email but isn't.

   * Verify that their Email field has a valid and correct email address.

   * It's also a good idea to quickly impersonate that user. Once you are acting as them, click the gear icon for settings, go to the Notifications tab, and just confirm they haven't disabled this specific notification.

 

I'd start with 3rd step.

 

Go through these steps, and I'm confident y

ou'll find the issue!

 

Mark this as useful if this helps.

 

Thanks.

View solution in original post

6 REPLIES 6

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @DoDo labs___ - As @ Anand2799 suggested, I would start by confirming Send when is set to "Event is fired" and Event name is FIG_TEST (assuming that's the name of your event in the event registry), then confirm the event log [sysevent] has an entry like this:

 

Created Name Queue Parm1 Parm2 Table State
  FIG_TEST   1a88d14a47a4dd90a7a05502e26d4327 user@example.com sys_user  

 

If that looks good, next I would check the email log [sys_email_log] for a record where event = FIG_TEST. I normally add the Email Logs related list to the Notification form to make this easier.

vignesh parthib
Tera Guru

Hi @DoDo labs___ 

I assume you're trying to trigger a notification through an event and control the recipient using the event parameters (specifically parm1).

In that case, you can use the following syntax:

This passes the sys_user record as parm1, which allows the notification to resolve the recipient when "Event parm 1 contains recipient" is checked.

gs.eventQueue("FIG_TEST", userek, userek, '');

 

If you want to trigger the notification and also include a value like the email address in the subject or body, you can pass additional data using parm2:

Here, parm1 is the user's sys_id (as a string), and parm2 is the user's email.

gs.eventQueue("FIG_TEST", userek, userek.sys_id, userek.email);

 

Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."