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

Anurag Tripathi
Mega Patron
Mega Patron

I think it is about the role, workflow script might be running in the user session and the user may not have sufficient role to delete the row.

 

Before this workflow activity, add a 1 second timer activity, that will change and make the rest of workflow execute in system session.

-Anurag

Hi @Anurag Tripathi,

 

Tried it and same is happening. Only the Service Offering Value is getting removed from the "sc_cat_item_subscribe_mtom" table. It is not clearing the entire record. Is there any other solution to delete the entire record? And will it be ACL issue? If so how can we overcome it?

 

Thanks,

Surya

Brad Bowman
Kilo Patron
Kilo Patron

Since this is working in Background I assume you are hard-coding the sys_ids in the two addQuery lines.  In the Workflow Run Script, what are you actually using on these lines?  Are you saying a field is cleared from the correct record on this table, but the record is not getting deleted?

Hi @Brad Bowman ,

 

Thanks for the reply. I'm passing the values of Catalog Item and Service Offering as sys_id in the addQuery. Yes, the Service Offering field is getting cleared and not the Catalog Item record from "sc_cat_item_subscribe_mtom" table. PFA, the screenshot.

Surya_Prakash_0-1697026856911.png

Thanks,

Surya