Automatically creating recurring tasks at specified intervals throughout the year
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2017 06:34 AM
Hi All,
I am looking for guidance/advice more than a technical solution.
I have a requirement from our facilities team to have repetitive tasks to be automatically created at specified intervals. For example, an 'office cleaning' task would be raised daily. 'Air Con maintenance' would be raised every 6 months and so on.
The 2 options I have considered thus far are scheduled jobs & a parent/child type workflow.
Scripted jobs
I have found examples on the community of people using scripts in scheduled jobs to create tasks. However, looking at the default interval choices it seems to be somewhat restrictive. I need to be able to schedule tasks to be raised every 2 workdays, once every 5 years, bi-annually, etc. I guess I could calculate the number of days & use that...
This method also requires the jobs to be set up by the admin team, which isn't the end of the world, but ideally the Facilities team (or any other team) would be able to create their own.
Workflow
The other method I explored briefly was a catalog item to raise a request/item (which would remain open indefinitely) and have the workflow create tasks on the item when needed.
This would be great if it works because the team would be able to view the job details at item level & have a list of previous tasks that have been completed, with all the notes, in one place.
I expect that others have had a similar requirement in the past & I'm hoping people can share what solutions they came up with?
Any help would be appreciated.
- Labels:
-
Best Practices
-
Scripting and Coding
- 14,148 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 09:38 AM
I am looking for something similar process for preventative maintenance requests for different departments at various properties. I was looking at creating a catalog item with very basic information, and then using a scheduled job to initiate and fill in the blanks. This would allow me to create the workflow and embed instructions in the task(s). So far, I have been unsuccessful with the execution of this. So any information/updates are greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2019 01:56 PM
I am looking for the exact same thing, so if someone achieves this. Update this thread 🙂
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2019 01:16 AM
Update:
thanks to Earl Duque: You don't need any scheduled job for this. You can instead just schedule a template: https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/administer/reference_pages/task/t...
Original answer posted below, just in case someone wants to know what i am referring to and how not to do it. Again, don't do it.
============================================================================
Hello,
I know i am pretty late to the party, but i recently got asked the same question from one of our developers and i thought i once read on the community about it. But as it seems, there is no answer yet. Let me suggest how i would solve this requirement and why:
Workflow
I would highly suggest, not to use a workflow here. Don't get me wrong, it is possible. However your workflow (as you stated) will remain running indefinitely. And this is why it won't work well. Workflows have a limit on how many actions they are allowed to perform. This means, that eventually your workflow will fail. Furthermore, a workflow should always represent a process, which in this case it clearly would not.
Scheduled job
This is what we should settle one. Running a scheduled job in the smallest needed timeframe will give you the best option here. "Daily" will probably be more than just fine. Now you've stated, thinking about it, however you have been discouraged by the lack of variety it will give you. This is where a scheduled job is indeed limited. However, i propose to use a new table for this. Here is how:
Create a new table with the following fields (minimum, add fields as you desire):
- reference field to a task
- reference field to schedules
- reference field to a user
Now here is what a record will do in this table:
You can now define a task that was once created, which you want to repeatedly create. Within the schedule field you can reference when that task must be created. The user field will contain the user, said task must be assigned to. If you want, you can extend this table to your desire. E.g. add a group field to assign the task to a certain group.
Your scheduled job will get a bit more complicated now. What you want to do is to query your newly created table. Then, run through all of the records and check, if the schedule is valid for the current timeframe (e.g. the current day) by using the answer from this community entry. Then, iterate through all the records, where this check evaluates to true. Get the task record referenced in each of the records. Then do something like this:
var task = thisIsYourSelecteTaskGlideRecord;
// reassign all attributes that need new values, clear unneeded values
task.description = null;
task.short_description = null;
task.work_notes = null;
// continue this for all fields you want to clear
task.assigned_to = your_scheduled_record.u_assigned_to;
task.assignment_group = your_scheduled_record.u_assignment_group;
// continue this for all fields your want to set values for
task.insert(); //-> this will insert your now modified task (the scheduled task)
And that is it. Now you have a very stable "framework" for allowing users to schedule tasks as they desire. All they need to do is to create the task manually once. Then, within this table, they can add a new record with a reference to this task, assigning it to themselves, adding certain attributes and then customise the schedule they want. If they do not find a appropriate schedule, they can even add their own.
Pro-Tip: Remember to set the task status to "In Progess".
Hope this gives you a rough guideline on how to implement both a stable and configurable solution without going absolutely above and beyond with platform and time invest.
Greetings
Fabian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2019 07:39 PM
Hi Fabian,
Thank you for the valuable information. Can you please share your codes with me - like how you are creating recurring tasks.
Thanks,
Manoj.