- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2022 02:14 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2022 03:15 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2022 02:21 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2022 03:11 AM
Hi Rohila,
In this :
gr.addQuery('parent_incident', current.sys_id); //modify proper field name.
I have to add the incident table field ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2022 03:12 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2022 02:28 AM
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();