Record not getting deleted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 04:49 AM
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2023 03:37 AM
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.');
}