how can i trigger an event from schedule job

anoopr77
Kilo Explorer

var gr = new GlideRecord('u_email_object');

gr.addActiveQuery();

gr.addEncodedQuery('u_expiration_dateBETWEENjavascript:gs.daysAgoStart(0)@javascript:gs.endOfNextWeek()');

//query above would find records active whose expiration date field value is today

gr.query();

while (gr.next()){

gs.log(gr.u_number);

gs.eventQueue('expiration.date',current,current.u_owner,current.u_alias);

  //gs.log("testing");

}

is there any syntax wrong while calling the event expiration.date??

1 ACCEPTED SOLUTION

Subhajit1
Giga Guru

Hi Rakesh,



Current won't work in Scheduled Jobs.


That is the reason your Event is not getting triggered.


Try using this:-


gs.eventQueue('expiration.date',gr,gr.u_owner,gr.u_alias);




Thanks,


Subhajit


View solution in original post

15 REPLIES 15

Kailash Bhange
Kilo Sage
Kilo Sage

Hi There,
I have Created Article to send Notification using Schedule Job, please take a moment to review and update feedback.

Notify using Scheduled JOBS in ServiceNow


https://community.servicenow.com/community?id=community_article&sys_id=1dd55f001b255010ada243f6fe4bcba8

If the article helps you, please mark it as Helpful, Bookmark it, subscribe it and your feedback would be much appreciated.


Thank You!
Regards,
Kailash