Simple dialog with field validation and control override method

Simple dialog with field validation and control override method:
class VKSalesOrderCloseDialog extends RunBase
{
    DialogField                 dlgHoldCode,
                                dlgReasonCode,
                                dlgNotes;
    MCRHoldCode                 holdCode;
    RetailInformationSubcodeId  reasonCode;
    Notes                       notes;

    #DEFINE.CurrentVersion(1)
    #LOCALMACRO.CurrentList
    #ENDMACRO
}
Object dialog()
{
    Dialog dialog = super();

    dialog.caption("@MCR10327");
    dlgHoldCode     = dialog.addFieldValue(extendedTypeStr(MCRHoldCode), holdCode);
    dlgReasonCode   = dialog.addFieldValue(extendedTypeStr(RetailInformationSubcodeId), reasonCode, "@MCR10280", "@MCR4410119");
    dlgReasonCode.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(VKSalesOrderCloseDialog, reasonCode_lookup), this);
    dlgNotes        = dialog.addFieldValue(extendedTypeStr(Notes), notes);

    return dialog;
}
boolean getFromDialog()
{
    holdCode    = dlgHoldCode.value();
    reasonCode  = dlgReasonCode.value();
    notes       = dlgNotes.value();

    return true;
}
public container pack()
{
    //return [#CurrentVersion,#CurrentList];
    return [#CurrentVersion];
}
public MCRHoldCode parmHoldCode(MCRHoldCode _holdCode = holdCode)
{
    holdCode = _holdCode;

    return holdCode;
}
public Notes parmNotes(Notes _notes = notes)
{
    notes = _notes;

    return notes;
}
public RetailInformationSubcodeId parmReasonCode(RetailInformationSubcodeId _reasonCode = reasonCode)
{
    reasonCode = _reasonCode;

    return reasonCode;
}
private void reasonCode_lookup(FormStringControl control)
{
    RetailMCRChannelTable::lookupReasonCodes(control);
}
public boolean unpack(container _packedClass)
{
    int version = conpeek(_packedClass, 1);

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

    return true;
}
boolean validate(Object _calledFrom = null)
{
    boolean ret;

    ret = super(_calledFrom);

    if (!holdCode)
    {
        ret = checkFailed("@VK7302");
    }

    return ret;
}
public static boolean main(Args args)
{
    VKSalesOrderCloseDialog salesOrderCloseDialog;
    boolean                 ret = false;
    SalesTable              salesTable;
    ;

    salesOrderCloseDialog = new VKSalesOrderCloseDialog();

    if (tableNum(SalesTable) == args.dataset())
    {
        salesTable = args.record();
    }

    if (!salesTable)
    {
        throw error(Error::missingRecord(tableId2pname(tableNum(SalesTable))));
    }

    if (salesOrderCloseDialog.prompt())
    {
        VKCallCenterIntegrationUtilities::createHold(salesTable.SalesId, salesOrderCloseDialog.parmHoldCode(), salesOrderCloseDialog.parmNotes(), salesOrderCloseDialog.parmReasonCode());
        ret = true;
    }
    return ret;
}
Usage:
ret = VKSalesOrderCloseDialog::main(dialogArgs);




 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags