- 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 08:40 AM
Hi Arhur, sure. That's how workflows work per design. When you include change tasks within your workflow, just put them on the order on which these need to be completed. Once the first task on the workflow flow is closed then the following one in the workflow is created.
What you're trying to do is already baked into how workflows work in ServiceNow
Thanks,
Bern

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2016 08:40 AM
Are you creating the previous task also from the workflow? If yes, you can use workflow scratchpad to store the sys_id of that task and use it in the current task to check if the state is completed or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2016 08:47 AM
Hi ,
Yes , I have 3 records in my additional table:
order:100: short description: test:
order 200: short description: test1
order 300: short description: test2
Firstly, the workflow should create the task (test), and then the second one etc, if the previous task(test) has completed state.
Can you give me a short example ?
I will be very grateful
BR
AS

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2016 08:50 AM
The most easiest way would be to add 3 create task activity in the workflow. Have each activity look only for one record, that is 100 or 200 order and so on. Select the checkbox 'wait' for completion in the create task activity. Selecting the checkbox will make the workflow to wait before creating the next task.