Friday, March 21, 2014

Test Dialog Enum Combo Box through Class

//TestDialogEnumComboBox

public class TestDialogEnumComboBox extends RunBaseBatch
{
    DialogEnumComboBox  dialogEnumComboBox;
    DialogField         dialogType;
    DialogRunBase dialog;
    SalesStatus salesStatus;


    #define.FieldNoTmp(600)
}
public Object dialog()
{
    Set enumSet = new Set(Types::Enum);
    dialog = super();


    dialogType = new DialogField(dialog, enumStr(SalesStatus), #FieldNoTmp);  
    dialog.addCtrlDialogField(dialogType.name());
    dialogType.init(dialog);
    dialogType.label("Sales status");
    dialogType.helpText("Select sales status.");
    dialogType.value();


    enumSet.add(SalesStatus::Canceled);
    enumSet.add(SalesStatus::Invoiced);


dialogEnumComboBox = DialogEnumComboBox::newParameters(null, dialogType.control().id(), enumNum(SalesStatus), enumSet, dialog.form());


    return dialog;
}
public void dialogPostRun(DialogRunbase _dialog)
{
    super(_dialog);  
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);


    if (dialogEnumComboBox)
    {
        // Specify the formRun (at this point the formRun is already available)
        // This is needed to track selection in the comboBox
        dialogEnumComboBox.parmFormRun(dialog.dialogForm().formRun());


        // Select a specific entry in the comboBox, if needed
        dialogEnumComboBox.select(SalesStatus::Invoiced);


    }
}
public boolean getFromDialog()
{
    boolean ret;
    ret = super();


    if (dialogEnumComboBox)
    {
        salesStatus = dialogEnumComboBox.selection();
    }
    return ret;
}
client server static ClassDescription description()
{
    return "DialogEnumComboBox example";
}
public static void main(Args _args)

{

    SR_TestDialogEnumComboBox testDialogComboBox = new SR_TestDialogEnumComboBox();


    if (testDialogComboBox.prompt())
    {
        testDialogComboBox.run();
    }
}
public void run()
{
    info(enum2str(salesStatus));
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...