Dialogfield - mandatory in Ax 2009

Hi,

How to make the dialog fields as mandatory. In Ax 4, there is a method mandatory for dialog fields. but in Ax2009 it is not available. How to resolve it.

Pls advise.

Thanks,

Maria

Hi Maria,

Check this out for making an dialog field as mandatory

FilePath workFolder;

Dialog dialog;
DialogField dialogField;
FormStringControl formStringControl;
FormGroupControl formGroupControl;
;

dialog = new Dialog( “Test” );
dialogField = dialog.addField( typeid( FilePath ), “Test1” );
formGroupControl = dialog.mainFormGroup();
formStringControl = formGroupControl.controlNum( 1 );

formGroupControl.mandatory( true );

Hello,

You are correct that mandatory() method is not available on DialogField objects in AX 2009. To make a dialog field mandatory in a dialog form you can override the validate() method of your class as shown below:

public boolean validate()

{

boolean ret = true;

if (!field)

{

ret = checkFailed(“Enter the field value”);

}

return ret;

}

The field variable is used to store the value entered in the dialog field of the dialog form which you retrieve in the getFromDialog() method.