Making a Field Mandatory on a Form

This question has suggested answer(s)

I have been trying to make a field mandatory on a form in AX 2009, I have tried the two ways i know:

  • Going to the datasource field and making it mandatory in the properties, which gives me the red wavy line in the box, but still allows me to click on and off the control and close the form without inputting any data.
  • And using a ValidateWrite method on the DataSource of the table;
    •  if(!creditCardTable.Zipcode)

                        ret = checkfailed(strFmt("Zipcode must be filled in!"));

  •  
    •  if (!CreditCardTable.Zipcode)

{

warning("Zipcode must be filled in!");

ret = false;

}

Do you know any other way of making the field mandatory when the client will have to input/choose a value for the control before closing the form window?

 

  

All Replies
  • Either approach you have done will work. The problem is those things do not get checked unless you "change" something.

    I bet that if you created a new record, your validations would be hit. I am also fairly certain if you took an existing record and tried to change *any* field on that record, your validations would be hit.

    But when you click on and off the control, you didn't change anything so no validations get triggered. When you close the form, AX will also detect you didn't change anything so it won't try to write the record (which is what triggers the validation on validatewrite).