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-11-2023 05:42 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 07:35 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 07:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 08:13 AM
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 08:18 AM
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))