Best Practice for overriding standard validations with extensions.

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?


Sign In or Register to comment.