HI how to send email notification on scheduled job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 03:04 AM
Hi,
i have a requirement to match the email address of the users in user table and email address in AD account table and if its matches it needs to do nothing , if its emails address of user table and AD table does not match it should send a notification to the group saying email address does not match in a scheduled job which runs every day.
i have used the below script but its not genertaing an email.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 03:37 AM - edited 09-19-2023 03:38 AM
Hi @siddharth26,
Create a new event in the Event Registry.
Trigger that event in your scheduled job, where parm1 and parm2 are optional:
gs.addEventQueue('<<event name>>', userGr, 'parm1', 'parm2');
Use that event in your notification record as trigger.
References:
GlideSystem - Global (servicenow.com)
Event registry (servicenow.com)
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 06:03 AM
Hi Peter,
Thanks , emails are getting triggered but for every mismatch its sending individual emails suppose there is 10 emails mismatch from user table to Ad email address 10 emails is been sent , i just need single email to be sent to a group with these 10 emails address mismatch details.
thanks
sid

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 06:29 AM
Then you will have to place the gs.eventqueue lower in your script, outside of the while loop.
Gather information regarding the users, in a way which suits you, and parse that in parm1 or parm2.
Something like this in the begin of your script.
var failedUserDetails = '';
Then in every mismatched user:
failedUserDetails += userGr.getDisplayValue() + ' ' + userGr.getValue('user_name') + '</br>';
In your notification you can use it as ${event.parm1}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.