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

Looks like it needs another } between the bottom two. If you hover over the red error markers it will tell you what is wrong, it highlights which curly braces correspond with each other so you can see which are unmatched.

Alicja1
Kilo Contributor

find_real_file.png

replace current with g_form

Alicja1
Kilo Contributor

I am also receiving syntax errors when pasting the script include...

find_real_file.png

You've pasted the script outside of the class syntax:

var ChangeTaskUtils = Class.create();
ChangeTaskUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	checkTasks: function(){
		var changeID = this.getParamter('sysparm_change');
		
		var gr = new GlideRecord('change_task');
		gr.addQuery('change_request', changeID);
		gr.addActiveQuery();
		gr.setLimit(1);
		gr.query();
		return gr.hasNext();
	},
	
	type: 'ChangeTaskUtils'
});