Require an incident for emergency change

Mark Petras
Mega Contributor

If someone is creating an emergency change we want to require at least one incident is added to the Incidents pending change related list. I am think this would be a business rule but I am not sure how to reference the related list. 

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Related list will appear only once the form is submitted. So, assuming you have to do a check on change table  

Type | is | Emergency

&&

State | is | .... //as per your need 

something as below for script should suffice your need.

(function executeRule(current, previous /*null when async*/) {

	var checkchildincident=new GlideRecord('incident');
	checkchildincident.addQuery('rfc',current.sys_id);
	checkchildincident.query();
	if(checkchildincident.getRowCount()<1)
		{
			gs.addErrorMessage('Ensure atleast once incident is attached for change.');
			current.setAbortAction(true);
		}

})(current, previous);

View solution in original post

4 REPLIES 4

Kieran Anson
Kilo Patron

When you say require, is this to allow the state to be changed to a certain value (i.e the change progressed)? 

Correct. In order to move the change from draft to the next stage we want to make sure the change has an incident tied to it. 

Aman Kumar S
Kilo Patron

Hey,

I think you are looking for an "Incident Fixed by Change" related list.

So, this is not a separate table but the incident table itself.

If you go to a incident record, In related records you will find Change request field, once you add a change, you can spot that incident in your related list on change form.

You just need to GlideRecord your incident table in the BR on Change table, an check if an incident is associated with that Reference field on Incident form.

 

find_real_file.png

Best Regards
Aman Kumar

Jaspal Singh
Mega Patron
Mega Patron

Related list will appear only once the form is submitted. So, assuming you have to do a check on change table  

Type | is | Emergency

&&

State | is | .... //as per your need 

something as below for script should suffice your need.

(function executeRule(current, previous /*null when async*/) {

	var checkchildincident=new GlideRecord('incident');
	checkchildincident.addQuery('rfc',current.sys_id);
	checkchildincident.query();
	if(checkchildincident.getRowCount()<1)
		{
			gs.addErrorMessage('Ensure atleast once incident is attached for change.');
			current.setAbortAction(true);
		}

})(current, previous);