How to Trigger the Notification from schedule job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2022 06:53 AM
All the changes in review state without approval for which actual end date passed at least 3 weeks ago a notification with a request to progress the change to the closure will be send to the change owner, assignment group(cc), change owners manager(cc), if the change will not be updated after 6 months change will be progressed automatically closure with close code: successful with issues and closure notes:" this change closed automatically".
This one I tried for first notiication.
var queriesFor4thWeek="active=true^state=0^approval=not requested^work_endRELATIVELT@dayofweek@ago@21";
var grChange=new GlideRecord('change_request');
grChange.addEncodedQuery(queriesFor4thWeek);
grChange.query();
while(grChange.next()){
gs.info('Change Number'+grChange.number);
gs.eventQueue('Demo2', grChange, grChange.assigned_to, gs.getUserName());
}
This one I tried for automatically closed
var queriesFor4thWeek="active=true^state=0^approval=not requested^work_endRELATIVELT@dayofweek@ago@21";
var grChange=new GlideRecord('change_request');
grChange.addEncodedQuery(queriesFor4thWeek);
grChange.query();
while(grChange.next()){
gs.info('Change Number'+grChange.number);
grChange.state=0;
grChange.close_code="successful with issues";
grChange.notes="this change closed automatically";
gs.eventQueue('Demo2', grChange, grChange.assigned_to, gs.getUserName());
}
but this is not working can you please help me to resolve it.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2022 07:03 AM
Hi,
What issue are you facing?
Notification not getting triggered or the script is not updating the change?
Can you put some logs and check if it is getting triggered.
And in second script, you did not write grChange.update();
Regards,
Sumanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2022 07:09 AM
Hi,
Is it showing in email logs?
Did you Register the event?
Refer to this link and let us know here if it worked?
Creating Schedule job to send notification.
Mark Correct or Helpful if it helps.
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2022 07:09 AM
There are a few things to check.
Make sure that you have created a record for your event in the event registry, make sure you have your notification set to trigger when your event is fired, and make sure that on the notification you have checked the box for "Event parm 1 contains recipient"
You can try running your code in a background script against a single change and see what happens. Something like:
var sys_id = "xxxx" //sys_id of a single change record.
var grChange=new GlideRecord('change_request');
grChange.get(sys_id);
gs.info('Change Number'+grChange.number);
gs.info('Param1:' + grChange.assigned_to);
gs.eventQueue('Demo2', grChange, grChange.assigned_to, gs.getUserName());
Then check the event log and see if your event is being created.
I hope this helps!
If this was helpful, or correct, please be kind and mark the answer appropriately.
Michael Jones - Proud member of the GlideFast Consulting Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!