How can you create a simple dialog box in Dynamics AX?
Asked Answered
P

3

13

How can you create a simple dialog box in Dynamics ax?

Phina answered 7/12, 2010 at 17:34 Comment(1)
you should accept your answer: it's a good, working solution.Jarid
P
25
static void DialogSampleCode(Args _args)
{
    Dialog      dialog;
    DialogField field;
    ;
    dialog = new Dialog("My Dialog");
    dialog.addText("Select your favorite customer:");
    field = dialog.addField(typeid(CustAccount));

    dialog.run();
    if (dialog.closedOk())
    {
        info(field.value());
    }
}
Phina answered 7/12, 2010 at 17:35 Comment(1)
field = dialog.addField(extendedTypeStr(CustAccount)); //AX 2012Wideopen
J
23

for really simple dialog boxes, use the Box Class:

    Box::info("your message");

or

    Box::warning("your message");

or

    if (Box::okCancel("continue?", DialogButton::Cancel) == DialogButton::Ok)
    {
        // pressed OK
        ...

or one of the other static methods (infoOnce, yesNo, yesNoCancel, yesAllNoAllCancel, ...)

Jarid answered 8/12, 2010 at 19:8 Comment(0)
S
0

DAX 2012 does not have "typeid" as a method. But you can use extendedTypeStr and then pass in either a known EDT or use the built in string length versions:

str getStringFromUser(str _prompt, str _title)
{
    str         userResponse = "";
    Dialog      dlg = new Dialog(_title);
    DialogField dlgUserResponse = dlg.addField(extendedTypeStr(String15), _prompt);

    // This prompts the dialog
    if (dlg.run())
    {
        try
        {
            userResponse = dlgUserResponse.value();
        }
        catch(Exception::Error)
        {
            error("An error occurred. Please try again.");
        }
    }
    return userResponse;
}
Sparrow answered 14/1, 2019 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.