preloader-matrix

Alfasith

Basic RunBaseClass and debugger flow in Dynamic AX

Hi,

1.Main class for declaration of fields.

class CustCreateRunBaseClass extends RunBase
{
    DialogField fieldAccount;
    DialogField fieldName;
    DialogField fieldGroup;
    DialogField fieldCurrency;
    DialogField fieldPaymTermId;
    DialogField fieldPaymMode;
    CustAccount custAccount;
    CustName custName;
    CustGroupId custGroupId;
    CurrencyCode currencyCode;
    CustPaymTermId paymTermId;
    CustPaymMode paymMode;
}

2. Main class – Code starts from here.
public static void main(Args _args)
{
    CustCreateRunBaseClass CustCreateRunBaseClass = new CustCreateRunBaseClass();
    if (CustCreateRunBaseClass.prompt())
    {
        CustCreateRunBaseClass.run();
        CustCreateRunBaseClass.insertTable();
    }
}

3. One constructor created it calls the class prompt.
protected Object dialog()
{
    Dialog dialog;
    DialogGroup groupCustomer;
    DialogGroup groupPayment;
    dialog = super();
    dialog.caption(“Customer information”); // Name to the dialog
    fieldAccount = dialog.addField(extendedTypeStr(CustVendAC),”Customer account”);
    fieldName =  dialog.addField(extendedTypeStr(CustName));
    dialog.addTabPage(“Details”); // Adding tab page
    groupCustomer = dialog.addGroup(“Setup”);
    fieldGroup = dialog.addField(extendedTypeStr(CustGroupId));
    fieldCurrency = dialog.addField(extendedTypeStr(CurrencyCode));
    groupPayment = dialog.addGroup(“Payment”);
    fieldPaymTermId = dialog.addField(extendedTypeStr(CustPaymTermId));
    fieldPaymMode = dialog.addField(extendedTypeStr(CustPaymMode));
    return dialog;
}

4. Debugger will not passes over but this following method is mound the fields into container.
It is the standard to convert or considering the fields in dialog as container but no use, so just return true.

public container pack()
{
    return conNull();
}

public boolean unpack(container _packedClass)
{
    return true;
}

5.Once the OK button clicks it calls the run() but just before click ie before super() following getFromDialog() will be called.

public boolean getFromDialog()
{
    custAccount = fieldAccount.value();
    custName = fieldName.value();
    custGroupId = fieldGroup.value();
    currencyCode = fieldCurrency.value();
    paymTermId = fieldPaymTermId.value();
    paymMode = fieldPaymMode.value();
    return super();
}

6. After click action following run() method will be called.

public void run()
{
    info(“You have entered customer information:”);
    info(strFmt(“Account: %1”, custAccount));
    info(strFmt(“Name: %1”, custName));
    info(strFmt(“Group: %1”, custGroupId));
    info(strFmt(“Currency: %1”, currencyCode));
    info(strFmt(“Terms of payment: %1”, paymTermId));
    info(strFmt(“Method of payment: %1”, paymMode));
}

7. Here I added user defined set of code for inserting my field values in to table
Here I called next to run()

private void insertTable ()
{
    MyTable     MyTable;
    MyTable.Addressing = custName;
    MyTable.HcmPersonnelNumberId = custAccount;
    MyTable.insert();
}

Regards,

Leave a Reply

Your email address will not be published.