I have a custom table that has a status field on it (Open,Closed,Deleted).
When someone deletes one of these records I want to actually change the Status field to Deleted and not actually delete the record. I put my code on the OnDelete to modify the record but the OnDelete trigger always wants to delete the record. So I can modify it but then it just gets deleted anyway. The EXIT statement does not work on the OnDelete trigger of a table. Thats what I need.
Any thoughts on how to do this?
0
Answers
Here's an example using the Item table. In OnDelete (first code to run):
In OnModify:
Etc. To test, just create a form with a temp record for Item and delete a few.
COMMIT will save your change of status and ERROR will stop its deletion
Deleted := TRUE;
MODIFY;
COMMIT;
IF Deleted THEN
ERROR('ok');
jwilder@stonewallkitchen.com
A status "Deleted"?
Imagine someone else but you having to do maintenance on this code.
Please reconsider this design and go to something more NAV-like.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Rest if Rec is deleted then it is stoped to actualy get delete. I dont think it can mess some thing as it it on top of the delete triger.
Dev
Option 1:
Option 2
Another way at form level which makes it hard for the user to delete by mistake.
Set the form Property DeleteAllowed = No
Add a Button [ Delete ]
Option 3:
A bit of both confirm or exit!
Then you can write a report to delete records at table level, I would also change the option Deleted to Closed!
HTH
David
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com