Using a CTASK to update CHG state

adamrasmussen
Giga Contributor

Hello,

I have been given a fairly comprehensive set of workflows for CHG tickets and one of the things that the team would like is to use the CTASK state to update the final state of the CHG request for routine changes.


Basically,

If 1 or more CTASKS are "Closed Incomplete" or "Closed Skipped" then the CHG Request needs to go back to Not Yet Requested and go through another approval cycle. (Closed incomplete means it didn't finish in the maintenance window, closed skipped means it wasn't attempted) and conversely if all CTASKS are closed complete, go ahead and move the CHG request (routine only) to Closed Complete.

I've encountered two challenges trying to make this work:

Opportunity 1 : I've tried making a business rule on the change_task before and after "State is one of Closed Incomplete/Closed Skipped" on insert and on update.   Nothing seems to work and nothing on the parent CHG ever changes even though I'm using Change request >> change request fields >> <field to update> in the actions area.

Opportunity 2 : Even when changing the states back to Not Yet Requested manually and then going through the basics (risk assessments etc.) and finally selecting Request Approval, the rest of the workflow doesn't trigger.   I'm guessing this is because there are still historical approvals in the table.   I want to keep this history, but I need to make sure the workflow ignores it and I'm stuck on that too.

Thanks!

1 ACCEPTED SOLUTION

In the run script activity, use this




var gr= new GlideRecord("change_task");


gr.addQuery("change_request",current.getValue("sys_id"));


gr.addQuery("state","IN",'4,7");


gr.query();


if(gr.hasNext()){


workflow.scratchpad.roll_back = "true";


}


else{


workflow.scratchpad.roll_back = "false";


}



Now , create a new if condition activity after this run script activity and in the advanced script section, use this



if(workflow.scratchpad.roll_back == "true")


answer='yes';


}


else{


answer='no';


}



Then link the rollback activity to yes condition of if.


View solution in original post

5 REPLIES 5

Abhinay Erra
Giga Sage

I am glad you got this resolved.