How to set up periodic schedule jobs

Bala13
Kilo Guru

Hi,

For example, 3 ECRb Change requests are rasied and waiting for aproval.

If there are 3 change requests and CRB recommendation field they have updated it in differennt intervals. 

So can we schedule a Job which will run periodically like set a time line of 3 hours. So every 3 hours it will check for which ECRB Change requests that CRB Recommendation field got updated and it will club all the changes and we can send an email?

Is this possible?

Please suggest me how to acheive this?

 

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

yes why not

1) Set Run - Periodically

2) Repeat interval - 3hrs

3) Starting time for the job to start

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks Ankur.

Actually for this requirmet, i have done like below.

1) Created an event

2) Crated a Business rule with the below condition and updated the script as below

3) Triggered an notification when even is fired.

4) CReated a email script for email notification

 

Need help on, how to trigger the event with schedule jon if i want to club the changes and check for the conditions periodically like i have asked in the question.

 

Business rule:

----------------

find_real_file.png

Script:

-------

(function executeRule(current, previous /*null when async*/) {


var cab_rec = previous.cab_recommendation.toString();

if(cab_rec.length==0) {
var gdt = new GlideDateTime();

//gdt.addSeconds(3600);//1 hour
gdt.addSeconds(60);//5 min

gs.eventQueueScheduled("u_ecrb_change_mom_custom.report",current,'','',gdt);
}
})(current, previous);

 

 

Hi,

You should query that table and apply proper query

1) form the query on your table

2) copy the query and use it as encodedQuery

3) Then trigger the event directly from schedule job which is running every 3 hours

var query = ''; // ADD YOUR QUERY HERE

var rec = new GlideRecord('tablename');

rec.addEncodedQuery(query);

rec.query();

while(rec.next()){

gs.eventQueue("u_ecrb_change_mom_custom.report",rec, recipient,'');

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur,

Here is the problem, from the change request table i cannot able to query the field CRB Recommendation changes.

can you please help me with that?