How to change the state of catalog task using Run Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 01:33 PM
Hi All,
I have a requirement where one of the variables will be appearing on the task and RITM and not on the catalog form view. I have been able to do the same. Now next part of the requirement is the variable which is a select box in nature comes with 3 options. This variable is mandatory in task form and the value of it determines the future activities.
Suppose the values are A, B and C.
If A is selected, state of task will get changed to Closed Complete.
If B is selected, state of task will get changed to Closed Incomplete.
If C is selected, state of task will get changed to Closed Complete and a new task will get created.
Following is my workflow:
The script that I have used in my Run Script is:
var ta = new GlideRecord('sc_task');
ta.addEncodedQuery('active=true^request_item='+current.sys_id);
ta.query();
if(ta.next())
{
ta.state = 3;
ta.update();
}
It is not updating the task state.
Could you please let me know where I'm wrong and how it can be corrected.
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 01:47 PM
As the workflow is defined on requested item table, the workflow will not proceed unless you have updated the state column on sc_task table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 01:48 PM
Refer Switch workflow activity and update your Switch Activity so that the workflow will move forward and update the task state.
Thanks,
Nitin.
Hit Like, Helpful or Correct based on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 01:55 PM
How is this to be updated so that workflow moves forward?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 02:53 PM
I will suggest you create a client script to update the state values and in the Catalog task activity you can create conditions and generate that new task you want to create.
Thanks,
Nitin.
Hit Like, Helpful or Correct based on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 03:38 PM
Add Wait for condition between 1st task and switch.
if(current.variables.select_box_variable_name !="){
answer = true;;
}