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

Anurag Tripathi
Mega Patron
Mega Patron

Were you able to find these logs??


gs.log(gr.u_number);


&&


gs.log("testing");


???




If yes then did you check the event logs to see if the event was fired or not?


-Anurag

HI anurag


gs.log(gr.u_number);


&&


gs.log("testing"); are appearing. but event is not getting triggered .:(


how ever in event logs i can see it is getting triggered , but in notifications i have added an user to get an email , this email notidfication   is not triggered


im sorry, i just realized that this is a scheduled job we are discussing. This script will not in jobs as you will not have current.



However if you have to use emails of some reports or extract then you can created a different script to achieve . other wiise in this scenario you must use GR instead of current


-Anurag