Thursday, December 22, 2011

Dynamics AX and database synchronization error

Due to huge customization in application we may come across database and application synchronization failure issue. Sometimes you will see this error when you add some new fields in CustTable or SalesTable, this is just for an example you can have this issue in any table or view.

Following job will forcefully synchronize all the tables in AOT.

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();
    errorStack = new StackBase(Types::String);

    lastIdx = 0;
        for (idx = lastIdx+1; idx <= totalTables; idx++)
            tableId = dict.tableCnt2Id(idx);

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

    errorTxt = errorStack.pop();
    while (errorTxt)
        errorTxt = errorStack.pop();
    info('Sychrnonization is now done.');

No comments:

Post a Comment

I will appreciate your comments !

Download large bacpac (sandbox database) to DEV environment much faster

As the LCS website gets slower and slower and the database backups get bigger and bigger.  Use AZCopy to download objects out of LCS asset l...