Update parent incident work notes when child incident is updated

anjaneyulubrill
Tera Contributor

Hi Experts,

 

I need your help experts on this requirment.

when child incident is updated then parent incident work notes should be updated.

script:

after update BR:

var childInc = new GlideRecord('childIncident');
childInc.addQuery('sys_id', current.parent_incident);
childInc.query();
if (childInc.next()) {
childInc.work_notes=current.comments.getJournalEntry(1);
childInc.update();
}

 

please correct me where i have mistake it's not working for me.

 

Thanks & Regards,

Anji.

3 REPLIES 3

AndersBGS
Tera Patron
Tera Patron

Hi @anjaneyulubrill ,

 

what you are describing is not according to ITL best practice or ServiceNow best practice.

 

in general you should always work on the parent ticket and not the child tickets. 

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/

jparman
Tera Guru

Hi Anji,

 

Please try this.

 

var parentInc = new GlideRecord('incident');
parentInc.get(current.parent_incident);
parentInc.work_notes = current.work_notes;
parentInc.update();

 

jparman_0-1675384464982.png

 

jparman_1-1675384491716.png

 

Please like my comment if it helps. Thanks!

Omkar Ranjane
Tera Guru

Hi @anjaneyulubrill 

There is OOB BR "Update Child Incidents" written to update child work notes when parent incident update. You can refer & create it same as per your requirement.

OR

just create Before Update BR with below code snippet.

(function executeRule(current, previous /*null when async*/) {
	var parentInc = new GlideRecord("incident");
	parentInc.get(current.parent_incident);
	parentInc.work_notes = current.work_notes.getJournalEntry(1);
	parentInc.update();
})(current, previous);

 If your question is solved, please close the topic by marking my answer "Accept as Solution". This will help others searching for a similar question and will remove the topic from the unsolved list.