Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Business Rule Delete

Avinash Dubey2
Tera Contributor

Create a Business Rule which will trigger when record is deleted in Incident table then delete a record in Customer Incident table for that incident.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Please use before delete business rule and update your logic as this

(function executeRule(current, previous) {

	var gr = new GlideRecord('u_customer_incidents'); // give your correct table name
	gr.addQuery('u_parent_inc', current.number); 
	gr.query();
	if (gr.next()) {
		gr.deleteRecord();
	}

})(current, previous);

Regards
Ankur

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

View solution in original post

12 REPLIES 12

@Avinash Dubey 

Did you try this out ? Do you have any confusion

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Please use before delete business rule and update your logic as this

(function executeRule(current, previous) {

	var gr = new GlideRecord('u_customer_incidents'); // give your correct table name
	gr.addQuery('u_parent_inc', current.number); 
	gr.query();
	if (gr.next()) {
		gr.deleteRecord();
	}

})(current, previous);

Regards
Ankur

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

Hi , 

 

Tried this approach .The record is not getting deleted from customer Incident tabel after deleting from incident table.

Hi,

Is this "Customer Incident" a scoped application?
If so, make sure that you have cross-scope access to delete records from Global scope.

Do you see any helpful error messages in the system log?

What is happening when you try to delete a record?

Hi,

are both the tables in same scope?

What's the error it shows?

Regards
Ankur

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