How to set up periodic schedule jobs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021 12:43 AM
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?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021 12:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021 01:36 AM
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:
----------------
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021 01:44 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2021 01:48 AM
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?