Scheduled Jobs
Scheduled Jobs in ServiceNow:
If we want that some action or some code get execute at an interval or time or it can be recurring such as daily, weekly, monthly etc. so we can do all these through Scheduled job. Schedule jobs provide us a flexibility to schedule the execution of reports, scripts etc.Even we can also run schedule job on demand through server-side scripts.
Some scenarios where we can use schedule jobs in ServiceNow are as mentioned below:
- Let's say we want, that a specific report will be delivered to stakeholder every week, every month or at any specific period.
Scheduled Jobs in ServiceNow is widely used and most important concepts which helps to generate or create lots of services.
There can be four states of schedule jobs:
- Ready: Ready state mean that the Job is ready to execute.
On Demand Scheduled Job in ServiceNow:
On Demand means that we can execute the schedule job when we want. As we know that schedule jobs are executed or run automatically daily, weekly, monthly, yearly etc. and there is also one option available on Run choice list i.e. OnDemand. So, we can execute schedule job from business rule and server-side scripts such as script include etc.Below is the code snippet which we can write in business rule, script include on any server side script to execute the scheduled job when we need it means OnDemand.
var objSchedule = new GlideRecord('sysauto_script'); //sysauto_script is a schedule job table name.
objSchedule .addQuery('name','--ScheduleJobName---');
objSchedule .query();
if(newGR.next()){
SncTriggerSynchronizer.executeNow(objSchedule ); //This will execute the schedule job mentioned above in addQuery.
}
In this way, we can run scheduled jobs in business rule and can run scheduled jobs in Script Include in ServiceNow.
objSchedule .addQuery('name','--ScheduleJobName---');
objSchedule .query();
if(newGR.next()){
SncTriggerSynchronizer.executeNow(objSchedule ); //This will execute the schedule job mentioned above in addQuery.
}
In this way, we can run scheduled jobs in business rule and can run scheduled jobs in Script Include in ServiceNow.
Thank you for sharing wonderful information with us to get some idea about that content.
ReplyDeleteServiceNow Online Training Hyderabad
ServiceNow Online Training India