- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 08:34 AM
Hello,
I want to create the change tasks creation via workflow (run script activity).
How to check if previous record has the completed state??
an example: I have an additional table which contains the information for the purpose of task creation, I have 3 columns ( Order, Short_description, Assignment Group).
I want to create the change tasks based on information from the table. The issue is, that the task should be created, if the previous task has the state = completed.
Does anyone know how to achieve it?
Thanks in advance for any answers!!!
BR
AS
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 09:07 AM
As I said if you are using run script activity to create a task. Use scratchpad variable as shown.
var task= new GlideRecord('sc_task');
task.initialize();
..
..
..
workflow.scratchpad.taskID=task.insert();
Now in your next activity before creating a task, check if the previous task is completed or not
var task= new GlideRecord('sc_task');
task.get(workflow.scratchpad.taskID);
if(task.state=='completed choice value'){
//insert task here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 09:47 AM
Above code should also work in wait for condition activity 🙂 I did not read about the custom table, in this case, limit can be set via custom table no of records count. But the above logic should work, it does not create a new task unless previous task in closed 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 09:07 AM
As I said if you are using run script activity to create a task. Use scratchpad variable as shown.
var task= new GlideRecord('sc_task');
task.initialize();
..
..
..
workflow.scratchpad.taskID=task.insert();
Now in your next activity before creating a task, check if the previous task is completed or not
var task= new GlideRecord('sc_task');
task.get(workflow.scratchpad.taskID);
if(task.state=='completed choice value'){
//insert task here
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 09:12 AM
I will do that!!, thx!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 09:16 AM
There is supposed to be 'N' number of tasks being created which needs the previous one to be completed and I don't see how this code will do that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2016 09:19 AM
We only need to check the previous task. If it was completed then set the
workflow scratchpad variable to the current task id. Or else rollback to
the same script
On Monday, September 5, 2016, kalai <community-no-reply@servicenow.com>