Best Practice for overriding standard validations with extensions.

majormarcell1988
Member Posts: 20
Hi,
Just as a quick example imagine the following is a standard code on a table:
Start Date - OnValidate()
DoStuff();
IF "Start Date" = 0D THEN
ERROR('You cant do that.');
What would be the best way allow 0D entry from my extension?
So far I have figured two ways, none of which I really like, just would like to ask your opinion.
Option 1:
Create a new field "Ext. Start Date", and replicate the validation code and modify as you wish. (In this case remove the error).
field(50000; "Ext. Start Date"; Date)
{
Caption = 'Start Date';
trigger OnValidate()
begin
DoStuff();
"Start Date" := "Ext. Start Date";
end;
}
Create a page extension, set the "Start Date" visible = false, and add the "Ext. Start Date"
Create an Install codeunit and set the "Ext. Start Date" to "Start Date"
Option 2
Subsrcibe to the Start Date OnBeforeValidateEvent with the following code
DoStuff();
Rec.MODIFY(TRUE);
COMMIT;
ERROR('');
What do you think, are there any other ways to achieve this without asking for events?
Just as a quick example imagine the following is a standard code on a table:
Start Date - OnValidate()
DoStuff();
IF "Start Date" = 0D THEN
ERROR('You cant do that.');
What would be the best way allow 0D entry from my extension?
So far I have figured two ways, none of which I really like, just would like to ask your opinion.
Option 1:
Create a new field "Ext. Start Date", and replicate the validation code and modify as you wish. (In this case remove the error).
field(50000; "Ext. Start Date"; Date)
{
Caption = 'Start Date';
trigger OnValidate()
begin
DoStuff();
"Start Date" := "Ext. Start Date";
end;
}
Create a page extension, set the "Start Date" visible = false, and add the "Ext. Start Date"
Create an Install codeunit and set the "Ext. Start Date" to "Start Date"
Option 2
Subsrcibe to the Start Date OnBeforeValidateEvent with the following code
DoStuff();
Rec.MODIFY(TRUE);
COMMIT;
ERROR('');
What do you think, are there any other ways to achieve this without asking for events?
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