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

Well, yes, I assumed that - but are you hard-coding them or using current..... which refer to reference fields/variables? Aside from the user vs System permissions issue that @Anurag Tripathi pointed out, the difference between running this in the background vs workflow is identifying the correct record.  I would submit that this script is not doing anything, or maybe deleting a different record rather than clearing a value then saving the update as there is nothing in the script to indicate that.  Add a workflow.info line inside the while loop to log (each) sys_id, then check the log on the workflow context tab on the RITM to make sure the expected record(s) are retrieved. You can also add a log line for gs.getUser() to confirm that the script is running as the System account, or if the timer activity needs to be increased or re-located.

Yes, we are passing it through "current.variables.variablename". Yes I done the same and got that the Workflow is running and clearing the "Service Offering" value with System account. Also, I tried to give 3sec of Timer and tested as well but happening the same, it is just clearing the Service Offering value.

Anurag Tripathi
Mega Patron
Mega Patron

Can you add some logs in the script to see what sys_id are you getting.

 

What are the delete ACL on the table, I'm asking because a field is getting deleted but the row is not.

-Anurag

Yes, tried to get sys_id and values are populating correctly. And there was an ACL which was on "delete" record on the table and it has an role of "Catalog Editor".

To Test, try to deactivate the ACL and try again.

Also hope you are passing the variable in the query with right type (eg , gr.addQuery('sys_id', ''+varA)) 

-Anurag