Can you help me

teja6
Kilo Contributor

Create a business rule 'Remove Temp Incident  Rule' , This should execute only whenever any record removed from 'Incident' table.
             - Query the incident number from 'incident_temp' table based on removed Incident Number record from 'Incident' table
             - Remove the corresponding incident record from 'Incident_temp' table

1 ACCEPTED SOLUTION

Advanced checkbox should be checked.

When to Run - before and delete checkbox should be checked.

Code will be this - 

 

var gr = new GlideRecord('incident_temp');
gr.addQuery('field_name', current.number); 
gr.query();

if(gr.next()) {
  gr.deleteRecord();
}

 

For Full Detail of Business Rules go through the below link - 

Create Business Rule

View solution in original post

6 REPLIES 6

Dylan Mann1
Giga Guru

Create a business rule on the Incident Table, click the Advanced checkbox. In the "When to Run" tab select Before in the "When" dropdown and the Delete checkbox. This way the rule only runs when a record is deleted on the Incident table. You can also add more conditions in the "Filter Conditions" section towards the bottom. 

In the advanced tab, add this code and change it as necessary to fit your needs:

var grIncidentTemp = new GlideRecord('incident_temp');
grIncidentTemp.addQuery('incident', current.sys_id); // Use whatever you named your Incident reference field as
grIncidentTemp.query();

if(grIncidentTemp.next()) {
  grIncidentTemp.deleteRecord();
}

Thank you Dylan