Record not getting deleted

Surya_Prakash
Tera Contributor

Hi All,

 

I'm using Workflow Run Script to delete record from "sc_cat_item_subscribe_mtom" table, when a new record was inserted or current record is getting removed using an Catalog. But the script is only deleting the 'Service Offering' from the table and not the entire record including 'Catalog Item'. Our requirement is to delete entire record but it is not deleting entire record. Please help on this. PFB, the script we are using.

Surya_Prakash_0-1697024878738.png

 

Note: Same script is working on Background Script when testing.

 

Script:

var grRel = new GlideRecord('sc_cat_item_subscribe_mtom');
grRel.addQuery('sc_cat_item', sys_id_of_catalog_which_we_are_updating);
grRel.addQuery('service_offering', '!=', sys_id_of_service_offering_we_are_updating);
grRel.query();
while (grRel.next()) {
grRel.setWorkflow(false);
grRel.autoSysFields(false);
grRel.deleteRecord();
}

 

Thanks,

Surya

10 REPLIES 10

Jagadish Sanadi
Kilo Sage

Hello Surya,

 

Try this

 

var grRel = new GlideRecord('sc_cat_item_subscribe_mtom');

grRel.addQuery('service_offering', '!=', offer);
grRel.addQuery('sc_cat_item', '=', cat);

grRel.query();
if (grRel.next()) {
   gs.info('Record found. Deleting...');
   grRel.setWorkflow(false);
   grRel.autoSysFields(false);
   grRel.deleteRecord();
} else {
gs.info('No matching records found.');
}