Add error message when adding Parent & child incident

Kusuma Sai
Mega Guru

Hi sir,
1. If i have a added a Parent incident by using reference field - then show the error message on the form
2, If i am adding a child incident by using related list - then show the error message on the form
for 1st scenario - i have written OnChange cs- it works perfectly.

for 2nd scenario - i have written after BR - update - works fine. but when added a parent incident then update/save the incident then it was showing the AfterBR error message. it won't comes when adding a incident in the reference field. please suggest
@Ankur Bawiskar , @Kieran Anson@AndersBGS 

Screenshot 2025-04-16 171652.jpg

1 ACCEPTED SOLUTION

@Kusuma Sai 

it's a expected behavior

the business rule will run when you change the reference field and it's a change to parent field and the BR condition will satisfy and it will throw error

Also when the record is linked with parent via New/Edit the same BR will run as parent field is getting updated.

I believe this much info should help you.

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

24 REPLIES 24

Ankur Bawiskar
Tera Patron
Tera Patron

@Kusuma Sai 

that's OOTB behavior

Unless and until you save the BR won't run and won't throw error

In 2nd scenario are you clicking New or Edit?

if you are not planning to use either of those buttons why not hide them?

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

Hi @Ankur Bawiskar sir,
I am using 'Edit' UI button to add child incidents. when add the child incident then show the error
Scenario -1 CS

KusumaSai_0-1744807321630.png

Scenario - 2 - After BR

"var par = new GlideRecord('incident');
    if (par.get(current.parent_incident)){
        gs.addErrorMessage('warning: This incident has been added as a child incident');
    }"
Tried this script also

KusumaSai_1-1744807399453.png

Please suggest if anything i have to add.

@Kusuma Sai 

if you don't want users to click Edit and add parent then hide that button from list control

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

Hi Sir, required both error messages.
1. if any end user added the new incident INC101 (parent incident) by using reference field(parent_incident) in the INC100 then show the error message ('added parent incident of this incident');

2. if another end user added child incident(INC104) by using related list UI Edit button in the INC103 then show another error message (''child incident is added in the parent")
please suggest @Ankur Bawiskar