Mandatory Field

I am trying to make the “Name” field of Customer card mandatory,means if somebody prss F3(i.e. Insert) in the Customer Card and don’t enter the Name field then it will not allow to come out of the Card form. I have made the “Not Blank” property of the “Name Field” as Yes. Also have written code in OnQueryCloseForm() trigger as: OnQueryCloseForm() : Boolean IF “Name” = ‘’ THEN ERROR(‘Enter Name’); It’s working fine. But what i mean to say whether it is a correct approach or not. Is there any other way to solve the problem.

You should put this control directly in the table: Table Customer OnInsert() or OnModify() TESTFIELD(Name);

With your approach, you are assuming that the user will close the form after creating a customer. He might also scroll to another record… I didn’t test, but I’m pretty sure your code won’t work if you create a customer and then move to another customer card.

Hi David, Yes u r right.The code is not working while moving one record to another. The code in OnInsert() & OnModify() trigger in Table is also not working in proper way.This is giving Error message while pressing F3 to insert new record.The Error is like"You must specify name in Customer No. =C00040". But the Customer No. “C00040” has not been created and displayed on the Customer card.

You should put the testfield only in trigger OnModify, but be aware that in this way the user will loose all the other information he/she modified whenever he/she forgot to insert the Name.

The C/AL Programming Standards manual says “Never Stop in OnModify” !! This trigger should never contain code that can stop the user from recording a change. What about looking at the form trigger: OnBeforePutRec? -john