Check Axapta Dialog

I found several posts and articles on the web that talk about checking form fields in dialogs, but none of the examples found work properly.

Can someone post a complete, short example of x ++ code that generates a dialog containing a single text field, performs a simple check (if text = "abc") on it, and either closes the window (returning the field value) if the check completes or generates an Infolog warning without closing the dialog if the check fails.

For those of us who are just starting out with x ++, I think that would be a good starting point for creating an actual working example.

Thanks!

+3
source share
2

AX 2009 , RunBase. DialogExample RunBase. , , MenuItem .

public class DialogExample extends RunBase
{
    DialogField dialogName;
    Name name;

    #DEFINE.CurrentVersion(1)
    #LOCALMACRO.CurrentList
        name
    #ENDMACRO
}

Object dialog()
{
    Dialog dialog = super();
    ;

    // Add a field for a name to the dialog. This will populate the field with 
    // any value that happens to be saved in name from previous uses of the
    // dialog.
    dialogName = dialog.addFieldValue(TypeId(Name), name);

    return dialog;
}

boolean getFromDialog()
{
    ;

    // Retrieve the current value from the dialog.
    name = dialogName.value();

    return true;
}

boolean validate(Object _calledFrom = null)
{
    boolean isValid;

    isValid = super(_calledFrom);


    // Perform any validation nessecary.
    if (name != 'abc')
    {
        isValid = checkFailed('Name is not equal to abc') && isValid;
    }

    return isValid;
}

Name parmName()
{
    ;

    return name;
}

public container pack()
{
    return [#CurrentVersion,#CurrentList];
}

public boolean unpack(container _packedClass)
{
    int version = conpeek(_packedClass, 1);

    switch (version)
    {
        case #CurrentVersion:
            [version,#CurrentList] = _packedClass;
            break;
        default :
            return false;
    }

    return true;
}

public static void main(Args args)
{
    DialogExample DialogExample;
    ;

    dialogExample = new dialogExample();

    // Display the dialog. This only returns true if the the user clicks "Ok" 
    // and validation passes.
    if (dialogExample.prompt())
    {
        // Perform any logic that needs to be run.
        info(dialogExample.parmName());
    }
}

, , , main, Ok. run , parm .

+5

, , , , AX, AOT , , "Tutorial_".

Tutorial_RunBaseForm - AOT, , .

+2

Source: https://habr.com/ru/post/1722345/


All Articles