How to change the state of catalog task using Run Script

ranabiswas
Giga Contributor

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:

find_real_file.png

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.

9 REPLIES 9

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.


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


How is this to be updated so that workflow moves forward?


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.


Add Condition to WF Activity



Screen Shot 2017-10-05 at 4.51.42 pm.png



Thanks,


Nitin.



Hit Like, Helpful or Correct based on the impact of the response


Deepak Kumar5
Kilo Sage

Add Wait for condition between 1st task and switch.



if(current.variables.select_box_variable_name !="){


answer = true;;


}