How to Close Problem Record when only all related incidents closed

chanikya
Kilo Sage

Hi,

i want to close PRB when related incidents all closed, if even one incident is in Working Progress then PRB should not closed.should be close all incidents then after only close PRB.

 

find_real_file.png

1 ACCEPTED SOLUTION

Sure. Just add this line below the addActiveQuery line. inc.addQuery('state', '!=', 6);

View solution in original post

12 REPLIES 12

Sure. Just add this line below the addActiveQuery line. inc.addQuery('state', '!=', 6);

Mark,

your script is working fine, but is it allowing only iwhen INC is closed, can we able to give access even if INC is resolved

Hi Chanikya,

 

Please try the below modified code of Mark's.

var inc = new GlideRecord('incident');

inc.addQuery('problem_id', current.sys_id);

inc.addQuery('state','!=','6');
inc.addOrCondition('state','!=','7');
inc.query();

if(inc.hasNext()) {

// If we find even one incident open, abort the update

current.setAbortAction(true);

gs.addErrorMessage('One or more incidents is still open and must be closed before closing this problem record.');

}

VigneshMC
Mega Sage

Try an before update BR when state changes to closed.

	var incident = new GlideRecord('incident');
	incident.addQuery('parent', current.sys_id);
	incident.addQuery('parent.state', '!=',7); //closed
    incident.addQuery('parent.state', '!=',6); //resolved
	incident.query();
	var count = incident.getRowCount();
	if(count != 0){
		gs.addInfoMessage("You have "+count+" open incident  which must be completed before this record can be closed");
		current.setAbortAction(true);
	}
	

not working