Trigger an event using job schedule

wakespirit
Kilo Guru

Dear all,

I could not find the steps to trigger an event using ScheduleJob.

Could anyone point me out steps by step

regards

 

1 ACCEPTED SOLUTION

As per the documentation, the gr is a glide record object. To be honest i'm not 100% sure on its purpose or function in this context. 

It's not something you can use and reference in your mail script. 

View solution in original post

18 REPLIES 18

The schedule Job is sending email every 5 minutes but ONLY for records where myFlag=true.

If there is no record with myFlag=true, the the event should not fired when schedule reach 5 minutes

regards

Then the skeleton code:

 

Gliderecord object initialization with the proper query

{

gs.eventQueue('event name',gliderecord object,'recipient-list');

}

 

 

what is recipient-lis in your sample ?

here are the scheduleJob script I have implemented :

//Build record object on asset table
var gr = new GlideRecord('alm_asset');
//Append the querry to generate the view record based on condition
gr.addEncodedQuery('u_send_record_to_mail=true');
gr.query();

//If tehre is at least one records, we fire the event
while (gr.next()) {
	gs.addInfoMessage("Event fired");
	gs.eventQueue("Asset.retired.ccchange", gr);
	
	//we reset the flag in order to avoid unneeded resend
	gr.u_send_record_to_mail = false;
	gr.update();
	
}

 

But issue i get in my script above is that I need to set the u_send_record_to_mail=false for all return records after event is fired, how can do that ? 

What you have above seems the code that will reset the flag. The recipient is the list of people you want to send the email. If you have the recipient on the notification, then you can ignore this