RITM is getting closed even if the mandatory fields are not filled.

Hari1
Mega Sage

Hi,

RITM is getting closed even if the mandatory fields are not filled this is happening with the workflow. But when i manually try to close the RITM i am getting the mandatory field to be filled alert.

REF::
find_real_file.png

1 ACCEPTED SOLUTION

Hari1
Mega Sage

The issue is fixed. Added the if condition at the end of the workflow before closing the RITM. So it checks the variable if it is empty or not. If it is not empty it check until the variable is filled by using the wait condition once filled. It sets the RITM to closed completed.

View solution in original post

6 REPLIES 6

Rakesh Mamidi
ServiceNow Employee
ServiceNow Employee

Hi,

You need to modify the workflow to check if the fields are filled in or not.

If it is the RITM fields, then data policy might help you. I see the mandatory fields here is the variables from the catalog items.

 

Hi,

Yes the field is from the variables. Can you help me out with the changes/script?

Hi Hemanth,

I don't think workflow would respect the mandatory variables or fields since it runs on server side.

How is the RITM getting closed?

Also that variable you have shown is that not populated during catalog item submission?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

The variable is a reference field to the change request table the variable change request field can be filled at any time after the catalog is submitted. The RITM is getting closed by the workflow. The below script does that once all the SCTASK are closed.

var cancelCount = 0;
var noncancelCount = 0;
var gr = new GlideRecord('sc_task');
gr.addQuery('parent',current.sys_id);
gr.query();
while(gr.next()){
	if(gr.state == '11'){
		cancelCount = cancelCount+1;
	}else{
		noncancelCount = noncancelCount + 1;
	}
}

if(noncancelCount > 0){
	current.state = '3';
	var gr =new GlideRecord('sc_request');
	gr.addQuery('sys_id',current.request);
	gr.query();
	if(gr.next()){
		gr.request_state = 'closed_complete';
		gr.update();
	}
}else{
	current.state = '14';
	var gr =new GlideRecord('sc_request');
	gr.addQuery('sys_id',current.request);
	gr.query();
	if(gr.next()){
		gr.request_state = 'closed_cancelled';
		gr.update();
	}
}