Tuesday, November 29, 2016

How to see beginning balance journals from your projects

There is a bug in AX 2012 R2/R3.

Beginning balance journals do not create transactions in ProjJournalTrans table; therefore, they won't be selected via the standard query.



This is a small fix to show beginning balance journals from the projects forms.

In ProjJournalFormTable class we need to redo datasourceLinkActivePre() method as follows:

public void datasourceLinkActivePre()
{
    QueryBuildDataSource    qbds;
    ProjTable               callerRecord;

    if (formRun                 &&
        formRun.args()          &&
        formRun.args().record() &&
        formRun.args().dataset() == tableNum(ProjTable))
    {
        callerRecord = formRun.args().record() as ProjTable;

        // if this is a beginning balance table we have no transactions in ProjJournalTrans
        // therefore, we need to update the query so that all related journals will be shown.
        if(journalTypeId == 2) // beginning balance
        {
            SysQuery::findOrCreateRange(journalTable_ds.query().dataSourceTable(tableNum(ProjJournalTable)), fieldNum(ProjJournalTable, JournalType)).value(SysQuery::value(ProjJournalType::BegBalance));
            SysQuery::findOrCreateRange(journalTable_ds.query().dataSourceTable(tableNum(ProjJournalTable)), fieldNum(ProjJournalTable, ProjId)).value(SysQuery::value(callerRecord.ProjId));
        }
        else
        {
        // End
            qbds = journalTable_ds.query().dataSourceNo(1).addDataSource(tableNum(ProjJournalTrans));

            qbds.joinMode(JoinMode::ExistsJoin);

            qbds.addRange(fieldNum(ProjJournalTrans, ProjId)).value(callerRecord.ProjId);
            qbds.relations(true);
        }
    }

    super();
}

Saturday, November 26, 2016

Back slashing menu items

It turned out to be a wrong decision to use a back slash character in menu item label. When it is used then in a menu, nothing tells you that something is wrong.



However, no chance to run this menu item from the menu.
So, avoid this and, maybe, other illegal characters for labeling your menu items.

Wednesday, November 16, 2016

Automate Error 351

From time to time we get the lovely CIL compilation Error:351. As suggested by many, for example, by André Arnaud de Calavon, we have to recreate XppIL folder with all its guts.

The sequence is the following (quotation)

1. Stop the AOS.
2. Rename the XppIL folder (C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\XppIL) to e.g. XppIL_old.
3. Start the AOS.
4. Perform a full CIL generation.
A new XppIL folder will be created when you start the AOS.
When the CIL has completed without problems, you can delete the renamed XppIL_old folder.

Clean and simple. However, I am too impatient to wait for the end of deleting this huge folder: Windows Explorer starts time estimation and it drags on.

So, I wrote two short batch files that can be run as administrator and spare your time and nerves.

First just to rename the existing folder.


@echo off
set folder="C:\Program Files\Microsoft Dynamics AX\60\Server\CHR_AX_DEV\bin\"
echo Rename %folder%  XppIL to XppIL_old?
pause
c:
cd %folder% 
ren XppIL XppIL_old
echo %folder%XppIL to  has been renamed to XppIL_old
pause

Second to delete all the files in the 'backed up' folder and its subfolders with no questions and infolog, then to delete the folder itself. As it said here, they must work faster than just removing the folder.

@echo off
set folder="C:\Program Files\Microsoft Dynamics AX\60\Server\CHR_AX_DEV\bin\XppIL_old\"
echo Delete all the files from %folder% and remove the folder?
pause
del /f/s/q %folder% > nul
rmdir /s/q %folder%
echo Folder %folder% removed
pause

The last remarque. Be sure that your service windows account running the AOS in question had Full permission to the C:\Program Files\Microsoft Dynamics AX folder and all its subfolders.

command line