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.
Below you will find the video which will help you understand through practical implementation that how you can create scheduled job and how you can do scripting in scheduled jobs.
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.
- Let's say we want that specific task record will get created and assigned to specific team every month in the system automatically.
- Let's say we want that specific report with email contains complete information will be delivered to stakeholders.
- Scenario: Auto closure of tickets such as Incident ticket under state pending customer action, where customer is not responding from last few days.
- Scenario: Auto closure of incident ticket when ticket is in resolved state from last few days.
- Let's say we can use schedule job to trigger different events weekly, monthly or at any specific period.
- We can generate Incident. Change and CI records through scheduled jobs.
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.
- Running: The job is in the process of carrying out a task.
- Queued: The job has been added to the scheduler queue and is waiting to run.
- Error: An error occurred in running the job.
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.
Video Tutorial of Scheduled Jobs in ServiceNow:
This video tutorial which will help you to understand scheduled jobs and let you know that how you can implement the same in ServiceNow.I hope above content and video provides you the complete understanding of Scheduled jobs in ServiceNow. Please provide your valuable suggestion below either they are good are bad. Our team will get motivated and will work to create valuable content. For more ServiceNow Tutorials and ServiceNow Video Tutorials you can navigate this website and our Basico ServiceNow Learning YouTube channel.
Hello,
ReplyDeleteI need help in conditon script in sysauto_template.
I would want to schedule a template based on date field (purchase_date) on CI (80 days after the date on CI). Please help.
Cheers,
Sam
Hi Great video.
ReplyDeleteI have specific request how do you use this idea to run scheduled back of ServiceNow update set.
That would be a very useful and practical example
Hi,
ReplyDeleteCan you please make video on service portal from scratch.. i am beginner
What is the use of this - if(newGR.next()) ; as we have not declared newGR anywhere ?
ReplyDelete