Incident state should be resolved if the Problem state is resolved

Tuhina Sharma
Tera Contributor

Hi Everyone, 

 

My requirement was to make the assign to field not mandatory if the incident state is on hold and the on hold reason is "Awaiting Problem", I create a UI Policy and this requirement is working fine. But once I add the incident which is in on hold state to the Problem and change the Problem state to resolve the Incident state is still in On-hold. But if the "assign to" field is not empty then the incident getting resolved with the problem.

 

TuhinaSharma_0-1716832167427.png

 

I created a business rule it is only working if the assigned to state is not empty. But the incident should be closed once the problem is closed if the assign to is filled or not doesn't matter.

 

I checked data policies, other BR conflicting or not but nothing found. 

Could you please help me on this.

 

Thanks in advance.

 

 

4 REPLIES 4

Saloni Suthar
Mega Sage
Mega Sage

Please share your script.


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

Tuhina Sharma
Tera Contributor

@Saloni Suthar 

TuhinaSharma_0-1716834930172.png

 

TuhinaSharma_1-1716835013653.png

 

 

(function executeRule(current, previous /*null when async*/ ) {
    var problemGr = new GlideRecord('problem');
    //if (problemGr.get(current.problem_id)) {
    problemGr.addQuery('sys_id', current.problem_id);
    problemGr.query();
    while(problemGr.next()) {

        if (problemGr.state == '4') {
            gs.info('Problem state is Resolved or Closed for incident: ' + current.number);
            current.state = '6';
            current.close_code = problemGr.close_code;
            current.close_notes = problemGr.close_notes;
            //current.assigned_to = problemGr.assigned_to;
            current.update();

        }
    }
})(current, previous);

 

@Tuhina Sharma 

Your business rule has to be on the problem with the condition when the problem state changes to resolved. You need to reverse your logic in the script too.


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

Amit Verma
Kilo Patron
Kilo Patron

Hi @Tuhina Sharma 

 

Try with the below updated Business Rule :

 

AmitVerma_1-1716868447628.png

 

AmitVerma_0-1716868422879.png

 

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

	// Add your code here
	var incGr = new GlideRecord('incident');
	incGr.addQuery('problem',current.sys_id);
	incGr.query();
	while(incGr.next()){
		incGr.state = '6';
		incGr.close_code = 'Resolved by problem';
		incGr.close_notes = current.close_notes;
		incGr.update();
	}

})(current, previous);

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.