2

To whom it may concern,


The idea is to make field validation conditionally possible just like Insert and Modify.

For example:

We can use the following condition in code in order to catch the error upon occurrence.


Codeunit:

If not TestCodeunit.run() then

error(GetlastErrorMessage);


Table:

Insert: procedure Insert(): Boolean

if not Rec.Insert() then

error(GetlastErrorMessage);


Modify: procedure Modify([RunTrigger: Boolean]): Boolean

if not Rec.modify() then

error(GetlastErrorMessage);


The same would be nice to have for Fields:


Field:

If not Customer.validate("VAT Bus. Posting Group") then

error(GetlastErrorMessage);


Currently you see the following:

Cannot implicitly convert type 'None' to 'Boolean'ALAL0122

procedure Validate(Field: Joker, [NewValue: Joker])

Calls the OnValidate trigger for the field that you specify.


I hope you consider this and make it possible as I believe that it wil solve a lot of issues when batch validating fields in a loop.

Like the following code would perform better when we can skip records which can not be validated and proceed with others.

Rec.Findset();

Repeat

if not field.validate(FieldName, NewValue) then

LogError()

else

UpdateRecNewValues();

Until Rec.Next() = 0;


Kind regards,


Handrén





Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team