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

Voona Rohila
Kilo Patron
Kilo Patron

Hi Avinash

Did you try anyhting so far?

You can query the customer incident table which matches your current incident and delete the record.

use below logic in your business rule.

var gr = new GlideRecord('customer_incident'); //enter customer incident table name
gr.addQuery('parent_incident', current.sys_id); //modify proper field name.
gr.query();
if (gr.next()) {
	gr.deleteRecord();
}

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hi Rohila,

In this :

gr.addQuery('parent_incident', current.sys_id); //modify proper field name.

 

I have to add the incident table field ?

parent_incident - this is the customer incident table field which stores incident value.

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

suvro
Mega Sage
Mega Sage

So you can create an after delete Business rule and you can then GlideRecord the customer incident table to delete the corresponding table

var cInc = new GlideRecord('<nameof the table>');

clnc.get('<field_name_referencing_incident_record>', current.sys_id);

clnc.deleteRecord();