Using Workflow to create multiple sc_tasks using a task template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2012 09:01 AM
I am trying to create a workflow that will assign multiple tasks at the same time to specific ITIL users, but the workflow creates an infinite loop and creates a stack overflow. Here is the scenario: I have a weekly audit that needs to be done in 5 separate locations and I want to generate 5 Service Catalog tasks, one for each location, every Monday morning.
I've created a template in the sc_task table that contains the information I need; Business Service, Category, Urgency, etc. When I open a new task I can apply this template, and I can even schedule this template as a Scheduled Job to run weekly, and it works perfectly. However, because you can only assign a template either to a team or an individual this would mean that I would need to create 5 separate scheduled jobs to run. I'm looking for a more efficient way.
I've noted that you can create a workflow and schedule that workflow to run as a scheduled job. So, for testing, I've created a simple workflow that goes like this: Start (always) > Create Task (always) — I've unchecked "Wait for Completion" and am using the "Task Values From" the task template I've created > End.
When I test this workflow it fails. I've communicated with ServiceNow's support and they told me that in this configuration the workflow conflicts with the sc_task table, causes an infinite loop, and the sc_task is not created. In addition, if I go back to the Scheduled Job and try to execute it, it fails. Again, according to SN, the scheduled job kicks off the workflow, which then fails, and it does not create the task. As soon as I disable the workflow the scheduled job starts working again. One other thing to mention. This simple workflow does create other type of tasks, i.e. change tasks. The problem only happens when I try to use sc_task.
Can anyone tell me why a workflow to create a sc_task would fail, but will work with other task items? Also, if someone has a good idea on a different way to create multiple tasks at the same time, I'd like to hear from them.
Thanks,
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2012 10:20 AM
just had a look at your (closed) incident, and the stack trace.
It looks like your activity was inserting an sc_task entry, which in turn made a new workflow fire, which inserted a new sc_task entry, and so on? Needless to say, that creates a big recursive mess.
Without seeing all the details, I would guess that you need to make sure your workflow, that you're running from the scheduled job, doesn't have a condition that will match when it then inserts those sc_task records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2012 02:47 PM
Thanks for your comments, James.
Your tip spurred me to take a closer look at other workflows. I ended up copying an existing Service Catalog workflow and modified it to suit my needs. Something strange was the fact that in the new workflow I created I had a Create Task item in the options list, but in the workflow I copied there was a Create Catalog Task item. It made all the difference in the world. I used the Create Catalog Task item and I didn't get the recursive problem.