Child incidents are not being "Resolved" when the Parent is Resolved

Jahnavi6
Kilo Expert

Hi,

We have a custom status called "Awaiting User Acceptance"(AUA). If we change the state from any other state to AUA in incident form, and save the changes, then this incident should be automatically resolved after 24hrs. For that, we created a scheduled job(scheduled script execution) to automatically resolve the AUA incidents.

Here is the code:

// This script automatically closes incidents that are resolved
// and haven't been updated in the specified number of days.
// To place a comment in the incident, uncomment the "gr.comments" line.


autoCloseIncidents();

function autoCloseIncidents() {
    var pn = 1; // This variable specifies the numbers of days before an incident is auto-closed
    var gr = new GlideRecord('incident');
    gr.addQuery('incident_state', 15); //AwaitingUserAcceeptance=15
    gr.addQuery('sys_updated_on', '<', gs.daysAgoStart(pn));
   // gr.addQuery('assignment_group','d625dccec0a8016700a222a0f7900d06');
    gr.query();
    while(gr.next()) {
    gr.incident_state = IncidentState.RESOLVED;
	//  gr.comments = 'Incident automatically closed after ' + pn + ' days in the User Awaiting Acceptance state.';
	//gr.active = false;	
	gr.update();
    }

Issue:

It is not resolving the child incidents associated to the parent incident. If I change the state to "IncidentState.CLOSED", then it is automatically closing the child incidents as well.

What should I do to auto-resolve the child incidents as well?

1 ACCEPTED SOLUTION

If you change an incident to Resolved while viewing the incident, do child incidents get updated to Resolved?  There is a condition on the OOB business rule

 current.state.changesTo(IncidentState.RESOLVED)

and your scheduled job is setting incident_state.  I know there's a BR that keeps state and incident state in sync, but maybe there's a timing issue, so if manually changing an incident State to Resolved works, then try changing the scheduled job script to 

gr.state = 6;
or maybe gr.state = IncidentState.RESOLVED;

View solution in original post

6 REPLIES 6

Ajaykumar1
Tera Guru

Hi Janhavi,

As you mentioned that their is an custom status called "Awaiting User Acceptance"(AUA), the OOTB business rule - Update Child Incidents checks for the parent incident's state i.e. Resolved and not for the custom state - Awaiting User Acceptance"(AUA).

You will have to update the business rule - Update Child Incidents to resolve child incidents when parent incident state changes to Resoled.

Note:- Do not make changes in an OOTB code, always make copy of OOTB code and then add your customizations.  

Regards,
Ajay

 

As mentioned in my question, I'm updating my parent Incident-"AUA" state to Resolved state(with the scheduled JOB), and the OOTB- Update Child Incidents also checks for "Resolved" state only.

Am I missing anything?