D365FFO – AX – X++ – 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:

1ret = VKSalesOrderCloseDialog::main(dialogArgs);

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...