Wednesday, May 16, 2018

Customer account statement "Field with ID '0' does not exist in table "AccountSumMap"

You may face an error while running Customer Account Statement report with "Balance other than zero" parameter checked. 

Following error shows up upon execution.


 "Field with ID '0' does not exist in table "AccountSuMap"

To fix this issue there is a KB 3146337 as mentioned below.


Monday, May 14, 2018

Multiselect lookup AX 2012

In this post will share code used to create multiselect lookup on runbase dialog.

class MultiSelectLookupExample extends RunBaseBatch
{
    // Dialog fields, groups and controls
    DialogField                 dlgFileName;
    DialogGroup                 dlgGrpFile, dlgGrpRoles;
    FormBuildControl            fbc;
    FormBuildStringControl      fbsc;
    SysLookupMultiSelectCtrl    sysms;

    // Packed variables
    FilenameOpen                fileName;
    container                   conRoles;
    container                   selectedRoles;

    #define.CurrentVersion(1)
    #define.Version1(1)
    #localmacro.CurrentList
        fileName,
        conRoles,
        selectedRoles
    #endmacro
}

public Object dialog()
{
    DialogRunbase       dialog = super();
    #resAppl
    xSysLastValue::getLast(this);
    dialog.addImage(#ImageEmployee);

    dlgGrpFile = dialog.addGroup("@SYS4000240");
    dlgFileName = dialog.addFieldValue(extendedTypeStr(FilenameOpen), this.parmFileName());

    dlgGrpRoles = dialog.addGroup("@SYS336367");
    fbc = dialog.formBuildDesign().control(dlgGrpRoles.name());
    fbsc = fbc.addControl(FormControlType::String, "@GLS221111");
    fbsc.width(400);
    fbsc.label("@GLS221111");

    return dialog;

}

public void dialogPostRun(DialogRunbase dialog)
{
    FormRun                 fr;
    container               con;
    super(dialog);

    fr = dialog.dialogForm().formRun();
    if (fr)
    {
        sysms = SysLookupMultiSelectCtrl::construct(fr, fr.design().control(fbsc.id()), queryStr(AXPSecRoleQuery), false, this.parmRolesSelect());
        con = conIns(con, 1, this.parmRolesSelect());
        con = conIns(con, 2, this.parmSelectedRoles());
        sysms.set(con);
    }
}

public boolean getFromDialog()
{
    boolean ret;

    ret = super();

    fileName = dlgFileName.value();
    this.parmRolesSelect(sysms.get());
    this.parmSelectedRoles(sysms.getSelectedFieldValues());
    return ret;
}

public container pack()
{
    return [#CurrentVersion, #CurrentList];
}

public boolean unpack(container packedClass)
{
    Version version = RunBase::getVersion(packedClass);
;
    switch (version)
    {
        case #CurrentVersion:
            [version, #CurrentList] = packedClass;
            break;
        default:
            return false;
    }

    return true;
}

public container parmSelectedRoles(container   _selectedRoles = selectedRoles)
{
    selectedRoles = _selectedRoles;
    return selectedRoles;
}

public FilenameOpen parmFileName(FilenameOpen   _fileName = fileName)
{
    fileName = _fileName;
    return fileName;
}

public container parmRolesSelect(container _conRoles = conRoles)
{
   conRoles = _conRoles;
   return conRoles;
}


public void run()
{
    #OCCRetryCount
    

    try
    {
        // Your logic goes here
        xSysLastValue::saveLast(this);
    }
    catch (Exception::Deadlock)
    {
        retry;
    }
    catch (Exception::UpdateConflict)
    {
        if (appl.ttsLevel() == 0)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::UpdateConflictNotRecovered;
            }
            else
            {
                retry;
            }
        }
        else
        {
            throw Exception::UpdateConflict;
        }
    }
    catch (Exception::DuplicateKeyException)
    {
        // retry in case of an duplicate key conflict
        if (appl.ttsLevel() == 0)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::DuplicateKeyExceptionNotRecovered;
            }
            else
            {
                retry;
            }
        }
        else
        {
            throw Exception::DuplicateKeyException;
        }
    }
}


Wednesday, May 9, 2018

D365 Extension Concluded


As we are aware of Overlayering concept used in previous version of AX where we used to modify metadata and source code, in higher layers which may increase the cost of upgrading a solution to newer version.

In AX7 onward Microsoft introduced a concept of extensions described as below.

Extensions


You can customize an application by using extensions. An extension enables you to add functionality to existing model elements and source code. Extensions provide the following capabilities:
  • Creating new model elements.
  • Extending existing model elements.
  • Extending source code using class extensions.
  • Customizing business logic, ways to customize business logic include:

o    Creating event handlers to respond to framework events, such as data events.
o    Creating event handlers to respond to event delegates that are defined by the application.
o    Creating new plug-ins.

So, in this post I would try to cover Extension on objects and what can be achieved using extensions.

Wednesday, May 2, 2018

Delete model in D365 Finance and Operation

ModelUtil.exe can be used for the purpose of removing or deleting a model. It is command prompt utility.

Just adding little more details here about the usage. At command prompt:

1. Browse to: K:\AOSService\PackagesLocalDirectory\bin folder.
2. Type in ModelUtil.exe /? to get to know about parameters.
3. I did import a custom model name was "LC_DEVModel" and I did remove it using following command:

K:\AOSService\PackagesLocalDirectory\Bin>ModelUtil.exe -delete -metadatastorepath="K:\AOSService\PackagesLocalDirectory" -modelname="LC_DEVModel"

Are you sure you want to delete model LC_DEVModel? (Y/N)
y


K:\AOSService\PackagesLocalDirectory\Bin>