Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Child incident's resolved date should be same as the parent incident's resolved date

phr
Tera Contributor

Hi All,

 

I have a requirement that the child incident's resolved date should be same as the Parent incident's resolved date. How to achieve this?

 

Thank you.

 

3 REPLIES 3

Deepak Shaerma
Kilo Sage
Kilo Sage

Hi @phr 

Create a New Business Rule.
Table : Incident
When to run : After Update
Filter : State Changes to Resolved(6)
Advance: tick 

Script: 

 if (current.state == '6' /Resolved/) {
        var resolvedDate = current.resolved_at;
        
        var childInc = new GlideRecord('incident');
        // Query for child incidents, adjust "parent" to your reference field
        childInc.addQuery('parent', current.sys_id);
        childInc.query();
        
        while (childInc.next()) {
            // Set the child incident’s resolved date to match the parent
            childInc.resolved_at = resolvedDate;
            childInc.update();
        }
    }



Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 

Thank you, this worked

Hi @phr 

Please mark it as Accepted Solution, this will help others for the same requirement.

Thanks & Regards 

Deepak Sharma