Delete condition of decision table records whose answers field value is same

1_DipikaD
Kilo Sage

 

Hi All,

 

In the Decisions table, there are thousands of records. Many of these records have the same answer and the same condition (for example, changerequest.location).

 

  • If multiple records share the same answer and the same location condition, then the changerequest.state condition should be removed, and only one record should remain active. All other duplicate records should be marked as inactive. Attached pictures for the same scenario .

1_DipikaD_2-1757173931687.png

 

1_DipikaD_1-1757173863560.png

 

 

  • If any records contain all three conditions (changerequest.state = new, assess, or scheduled), those records should be deleted. For example below picture matches to this scenerio. 

1_DipikaD_3-1757174259276.png

Is it possible to do so or will have to handle manually ? Please let me know if you need more info about it . 

 

Thank You

 

1 REPLY 1

Rafael Batistot
Tera Sage

Hi @1_DipikaD 

 

May you try via background script 

 


var gr = new GlideRecord('x_your_decision_table');
gr.addQuery('changerequest_state', 'IN', 'new,assess,scheduled');
gr.query();

while (gr.next()) {
gs.info("Deleting record sys_id=" + gr.getUniqueValue() + " with state=" + gr.changerequest_state);
gr.deleteRecord();
}