如何在Dynamics AX中创建简单的对话框?

13

在Dynamics ax中如何创建一个简单的对话框?


3
你应该接受你的答案:这是一个好的、可行的解决方案。 - user85421
3个回答

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());
    }
}

11
field = dialog.addField(extendedTypeStr(CustAccount)); //AX 2012 - ian_scho

23

对于非常简单的对话框,使用Box Class

    Box::info("your message");
或者
    Box::warning("your message");
或者
    if (Box::okCancel("continue?", DialogButton::Cancel) == DialogButton::Ok)
    {
        // pressed OK
        ...

或者使用其他静态方法(infoOnce, yesNo, yesNoCancel, yesAllNoAllCancel, ...)之一。


0

DAX 2012没有"typeid"方法。但是您可以使用extendedTypeStr,然后传入已知的EDT或使用内置的字符串长度版本:

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;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接