Hi All,
When I create a new record in Purchline then in my custom table, also record got inserted. And it is working fine.
Suppose , I delete any line from PurchLine then i like to delete the same record from my custom table.
I have a parameter, based on the parameter the record got inserted in my custom table. In the similar way, I try to delete the record from my custom table
For this, I wrote below code in Delete method on PurchLine extension class
public void delete(boolean _showInfoDelReserv , boolean updateOrderLineOfDeliverySchedule) { PurchQtyTracking purchQtyTracking,purchQtyTrackingDelete; RefRecId recId; PurchParameters purchParameters; purchParameteres = PurchParameters::find(); if (purchParameters.PurchLineQtyChecking == noyes::Yes) { select * from purchQtyTracking where purchQtyTracking.RefRecId == this.RecId; if (purchQtyTracking) { recId = purchQtyTracking.RefRecId; } next delete(); // if any record delete from purchline then the same record should delete from PurchQtyTracking also if (recId != 0) { delete_from purchQtyTrackingDelete where purchQtyTrackingDelete.RefRecId == recId; } } }
the requirement is -
If the parameter set to YES -
if record exist in PurchQtyTracing table then it should DELETE the record from both tables - Purch Line & PurchQtyTracking
If record NOT exist in PurchQtyTracking table, then it should DELETE record forom PurchLine. only
But when I tried to delete record form PurchLine then I got message "PurchLine.delete method called incorrectly"
If parameter is set to NO
then it shuold called standard delete operation only
Note - I not tried for delete action because the above delete operation execute based on parameter.
In delete action we can't set parameter. And it will work globally. So, I go for code in PurchLine - delete method
Pls give me more shed on this.
thansk!
thanks Mohit & Girish,
Now Its's working fine
Also, Can you try moving next statement out of the if loop.
If it's an optional parameter, I think it's not compulsory to call that in the next keyword.
I am not sure there. Please give it a try.
Thanks,
Girish S.
Hi, You are calling delete incorrectly, please add parameters same as standard method
next delete(_showInfoDelReserv , updateOrderLineOfDeliverySchedule);
Okay Girish
You can use either of them. It depends on the situation and on the developer hands to go for event handler or COC.
There are no recommendations to particularly use COC or event handler.
Thanks,
Girish S.
sure Girish, let me check and will update you.
CoC and Event handler - I know that how to call. Kindly let me know which one is recomanded to use ?
I know Pre or Post event handler similar to next call before custom code and after custom cide.
pls give me more shed on this.
thanks!
Try the same logic on the delete event handler instead of COC.
Thanks,
Girish
Exactly on the next delete()
Hi,
Have you debugged the code written in the delete method. Exactly at what line the error is throwing?
Thanks,
Girish S.
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,836
Most Valuable Professional
nmaenpaa
101,156