hi ,
I need some pointer and advice here. I would like to delete a sales order card , when i press F4 i want to build a trigger to save all the data in sales order header into another backup table before the sales order header data being deleted. The reason why i want to do this is to revise data that have been deleted. Is there anyone can help me in this problem? Thank you
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
RIS Plus, LLC
I have block entire chunck of code in OnDelete and i create a new order in sales order header and then i press F4 to try to delete the sales order and my sales order that just created was deleted!! :shock:
i thought that if i block entire chunk of code in the OnDelete in sales header it will not allow me to delete the sales order header that i have created ???
please advice , thank you
The reason why i cant used the archived function is the user does not want to do so , else it would have save me a lot of efford to do so....please advice thank you.
Yes, it was deleted, you must insert Error in this trigger, if you want to disallow deleting. If no code is in this trigger, record is deleted without any action (without deleting linked rows, dimensions etc.....!!!)
Second point where disallow user to delete something is trigger OnDeleteRecord on form - if you return false, nothing is deleted, if you return true, all is OK and record is deleted with calling OnDelete trigger and after that trigger, recor is deleted.
OnDelete trigger does not delete the record, it only do some additional actions. Record is deleted after this trigger if no error occured... 8)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
If you block all the code in the OnDelete trigger, that means that you make the system not do anything, so there is nothing stopping the user from doing this. If you want to not allow deletion of sales orders, then you should program an error in that trigger and no user will ever be able to delete them anymore.
What I have against programming data operations on the form is that you'd have to program the same thing on every form that accesses the table. If you program it in the table, it will automatically happen each time you put the table on a new form.
RIS Plus, LLC
I manage to fix this problem, my solution in OnDelete of Sales Header and Sales Line table i add in transferfields and insert code into the backup salesheader and salesline table.
Thank you for advice again