Wednesday 28 December 2011

"An invalid directory structure for Microsoft Dynamics AX was detected"


Running AX 2009 Client raises error: "An invalid directory structure for Microsoft Dynamics AX was detected"
We came across an issue recently where the Microsoft Dynamics AX 2009 Client was installed ,However after deployment when the client is run from the desktop systems we got a pop window with an error and clicking ok closes the client down:


 Error in text:
An invalid directory structure for Microsoft Dynamics AX was detcted. The subdirectory \Client\bin does not exist.

Upon further investigation, when we ran regedit to look at the registry keys created for the AX Client configuration, indeed it had incomplete path to the client\bin folder. The cause of teh error message. The issue occured on any Windows XP/Vista/7/2003 R2/2008/2008 R2 platform whether its 32bit or 64bit. The paths recorded in the registry were:

[HKEY_CURRENT_USER\Software\Microsoft\Dynamics\5.0\Configuration\Original (installed configuration)]
"bindir"="\Client\Bin"
"datadir"="Client\Data"
"directory"="\Client"
and the correct registry paths should have been (on an x64 system):
[HKEY_CURRENT_USER\Software\Microsoft\Dynamics\5.0\Configuration\Original (installed configuration)]
"bindir"="C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin"
"datadir"="C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Data"
"directory"="C:\Program Files (x86)\Microsoft Dynamics AX\50\Client"
(x86 system):
[HKEY_CURRENT_USER\Software\Microsoft\Dynamics\5.0\Configuration\Original (installed configuration)]
"bindir"="C:\Program Files\Microsoft Dynamics AX\50\Client\Bin"
"datadir"="C:\Program Files\Microsoft Dynamics AX\50\Client\Data"
"directory"="C:\Program Files\Microsoft Dynamics AX\50\Client"
manually modifying the registry keys with correct values, resolves the issue and allows clients to be run without any errors.

Tuesday 13 December 2011

Find all display methods in a table


One of my colleague asked this question to me ,
I used the class  “SysDicttable” , to start with and it helped .
I came up with the job mentioned below ,


static void getListOfDisplayMethods (Args _args)
{
    SysDictTable dictTable;
    CustTable custtable;
    List methodList = new List(Types::String);
       ListEnumerator enumerator;
       int i;

    ;

   //77 is the ID of Custtable, you can replace this with out tableid/tablename
    dictTable = new SysDictTable(77);


    methodList =dictTable.getListOfDisplayMethods();
    enumerator = methodList.getEnumerator();
    while(enumerator.moveNext())
    {
    info(enumerator.toString());
    i++;
    }
  
    info(strfmt("no of methods %1",i));
     info(strfmt("no of methods %1",dictTable.objectMethodCnt()));

}

Happy DAXING  J

Cannot execute a data definition language command on (). The SQL database has issued an error.,


While Synchronizing the database , some times we get the  following error , without knowing the tables name ,which caused the issue


Run the below job , in order to get the table name
static void forceDbSynchronize(Args _args)
{
    Dictionary              dict;
    int                     idx, lastIdx, totalTables;
    TableId                 tableId;
    Application             application;
    SysOperationProgress    progress;
    StackBase               errorStack;
    ErrorTxt                errorTxt;
    ;

    application = new Application();
    dict = new Dictionary();
    totalTables = dict.tableCnt();
    progress = new SysOperationProgress();
    progress.setTotal(totalTables);
    progress.setCaption("@SYS90206");
    errorStack = new StackBase(Types::String);

    lastIdx = 0;
    try
    {
        for (idx = lastIdx+1; idx <= totalTables; idx++)
        {
            tableId = dict.tableCnt2Id(idx);
            progress.setText(dict.tableName(tableId));

            lastIdx = idx;
            application.dbSynchronize(tableId, false, true, false);
            progress.incCount();
        }
    }
    catch (Exception::Error)
    {
        errorTxt = strFmt("Error in table '%1' (%2)", tableId, dict.tableName(tableId));
        errorStack.push(errorTxt);
        retry;
    }

    setPrefix("@SYS86407");
    errorTxt = errorStack.pop();
    while (errorTxt)
    {
        error(errorTxt);
        errorTxt = errorStack.pop();
    }
}