Validate delete

jimmyf
Member Posts: 104
What is the best way programatically to stop a user deleting a record if certain conditions are met?
thanks
thanks
0
Comments
-
You would program this condition in the OnDelete trigger of the table. Mind you, that only works when someone is manually deleting records, and when DELETE is called from C/AL code with parameter TRUE. When DELETE is called with FALSE, it does not execute logic in the OnDelete trigger, so in that case you need to also add the condition to whatever process is deleting the record.0
-
You can also do this on the OnGlobalDelete function in Codeunit 1. Put an error statement in there and log deletes (in the Change Log Setup) for whatever table to you want to control.
Of course, this requires the change log granule.0 -
"Certain conditions" usually apply to individual tables. I would always program conditions like that in those tables themselves. If you program codeunit 1 to handle exceptions for specific tables, you would always have to move individual tables with codeunit 1 when you do object maintenance. What kind of issues would come with that if you are in the middle of development for 35 tables, and only 2 of them are tested and approved? You would have to wait until development for all the other ones is done to move stuff out to production. That's asking for object conflicts in my opinion.
It's very smart thing to do for global conditions though, I can definately see there's a lot of potential in that approach. Just not for conditions specific for individual tables.0 -
Actually I meant that you would check for log deletes in change log setup table, not the codeunit.0
-
Just a bit off topic - what percentage of customer's would you say get the change log granule?
We for one don't.. Is this a sql thing or available in native too.
Which version did it appear in?
Sorry for the tangent & thanks.0 -
I would say about 50% of our clients get it, maybe a bit less. Yes, it works for both native and SQL.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions