When a child record state has been changed, update the work notes of the parent record.

purnendu
Tera Contributor

how can i achieve it through flow designer.

 

When a child record state has been changed, update the work notes of the parent record Stating “the state of the child has been changed to new state value of child incident.

Any help will be Appreciated.

Thanks in Advance.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@purnendu 

you can use after update BR or flow designer for this

what did you start with?

Something like this in after update BR on incident

Condition: State Changes && Parent is not empty

Script:

(function executeRule(current, previous /*null when async*/ ) {
    var parent = new GlideRecord('incident'); // Change 'incident' to the parent table name
    parent.addQuery('sys_id', current.parent).addOrCondition('sys_id', current.parent_incident);
    parent.query();
    if (parent.next()) {
        // Update the work notes of the parent record
        parent.work_notes = 'The state of the child has been changed to ' + current.state.getDisplayValue();
        parent.update();
    }
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @purnendu 

 

I am not sure what your use case is because if a parent record has five children and every child gets updated, then it adds it to the parent. As soon as it is added to the parent, it is considered work notes, and an email will trigger the group. What is your exact use case?

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

AndersBGS
Tera Patron
Tera Patron

Hi @purnendu 

 

please notice that best practice is to work on a parent ticket where comments will be copied to child, not the other way around.

 

 What is the business case for the need you’re asking?

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

 Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Ankur Bawiskar
Tera Patron
Tera Patron

@purnendu 

you can use after update BR or flow designer for this

what did you start with?

Something like this in after update BR on incident

Condition: State Changes && Parent is not empty

Script:

(function executeRule(current, previous /*null when async*/ ) {
    var parent = new GlideRecord('incident'); // Change 'incident' to the parent table name
    parent.addQuery('sys_id', current.parent).addOrCondition('sys_id', current.parent_incident);
    parent.query();
    if (parent.next()) {
        // Update the work notes of the parent record
        parent.work_notes = 'The state of the child has been changed to ' + current.state.getDisplayValue();
        parent.update();
    }
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader