
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:36 PM
Hi Team,
There is a requirement that when we create tag in Order Task table, it should copy the same to Customer Project Task table. And when we delete the tag from Order Task, it should also delete the same same from Project task.
Copying part is working fine but deleting is not deleting the record. Below is the BR written after Insert and Delete
In Condition I am checking the table is one of
"sn_ind_tmt_orm_order_task
customer_project_task"
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:49 PM
Hi,
Create separate BR for Delete operation and use "Before" BR for delete Operation.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:53 PM
If your current BR when to Run condition is "After" then your script part will not be able to read the current record values as it is already deleted and no longer available in database.
In such cases we can use "Before" BR and with highest order and perform the related cleanup operations.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:48 PM
Hi Ankur,
It looks like there might be an issue in your delete logic. Specifically, the addQuery for deleting records might not be filtering the records correctly. Instead of using 'ord_task.sys_id' in the addQuery, you should use 'current.table_key', as it is the key you're trying to match when deleting the record. Additionally, it's good to make sure that the label condition is also included in the delete query.
Here's the modified delete logic:
if (current.operation() == 'delete') {
gs.info('Will perform delete');
c_task.addQuery('table_key', current.table_key);
c_task.addQuery('label', current.label); // Make sure to include label in the delete query
c_task.query();
gs.info('Rowcount to be deleted:' + c_task.getRowCount());
while (c_task.next()) {
gs.info('Got the record to delete');
c_task.deleteRecord();
}
}
This modification ensures that the delete query is filtering records based on the current Order Task's key ('current.table_key') and label ('current.label'). Also, note the use of a while loop to delete all matching records if there are multiple records with the same key and label.
Please mark it helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:57 PM
Hi Iraj,
It seems the deletion part is not working still, I am not able to see the info message which I put to test for delete.
I have written this BR is scoped application for OMT , is there any issue because of that or do we need to write this BR in Global scope? or there is some other issue,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:49 PM
Hi,
Create separate BR for Delete operation and use "Before" BR for delete Operation.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 10:53 PM
If your current BR when to Run condition is "After" then your script part will not be able to read the current record values as it is already deleted and no longer available in database.
In such cases we can use "Before" BR and with highest order and perform the related cleanup operations.
Thanks
Anil Lande