The CreatorCon Call for Content is officially open! Get started here.

Prevent users from moving the Change to the next State before the CSTASK is completed

Alicja1
Kilo Contributor

I have a Workflow for a Standard Change in which I would like to prevent the users from moving the Standard Change to the next State (this is done manually by clicking on the button or setting the 'State' filed to the desired state) before the CTASK created on this state (creation via Workflow) is set to one of the 'Complete' statuses. 

In situation when the user clicks on the button of the next State and the CSTASK is still open, a message should be displayed indicating that the State cannot be changed because the task(s) have not been completed.

How can I best achieve this? I have read many posts and some people advise UI Actions, others Business Rules but due to my limited knowledge of scripting I cannot figure it out myself..

I appreciate your help!

Alicja

31 REPLIES 31

Cut line 4 and 5 and paste in below },(line 19)

David Stutter
Tera Guru

I created two fields on the change table:

* Change has Task

* All Tasks done

 

They are updated through a business rule on the change tasks.

This makes it a lot easier to handle, for example automatic state transition in a workflow: If all tasks done -> next state.

 

For the condition of a specific state transition is only possible if all tasks are done:

https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/change-management/task...

 

Just adding to the function canMove:

if(!this._gr.u_has_task) {
 gs.addErrorMessage('Change Requests must have at least one Change Task');
 return false;
}