Search code examples
dialogaxaptadynamics-ax-2012x++

How to assign value in DialogField from code?


I created a Dialog , when I launch the Dialog I want to assign a value for field.

I have this code:

Dialog dialog;

myDialogField = dialog.addField(enumStr(myEnumType));
myDialogField.value(myVariableEnum); 

dialog.run();

With this code I can not assign variabe. I launch the Dialog by button on Form , in a class I saw the really value in myVariableEnum but I don't know how to assign.

Thanks all,

enjoy!


Solution

  • Your dialog needs to be instantiated as FH-Inway pointed out, but you also need to use the field.value() as a getter to use the fields value after you run the dialog:

    Dialog dialog;
    DialogField myDialogField;
    
    dialog = new dialog();
    myDialogField = dialog.addField(enumStr(NoYesError), "Values : ");
    myDialogField.Value(NoYesError::Yes);
    
    dialog.run();
    
    info(myDialogField.value());//This gets the value of the field after the dialog is run.
    

    Resulting dialog box