web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Add Index to System Table

(0) ShareShare
ReportReport
Posted on by

Our AccesRightList Table needs an index added, I can add it from the SQL SSMS side but when we synchronize the tables I lose the index.  But since the Table isn't in the AOT->Data Dictionary->Tables I do not have the ability to add the index through AX itself.  

Any suggestions on how to maintain a AX System Table that isn't in the Tables Node of the AOT?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    What do you mean add it to the deployment process to create the index?

  • Community Member Profile Picture
    on at

    Yes this is our Production environment.  I am not following what you mean at all.  Is there a class we can add steps to when it does do a Database synchronize afterwards it can recreate the index?  

    Your answers seem out of context so its hard to follow what you are suggesting.  

  • Community Member Profile Picture
    on at

    Yeah that would work if the only time the database was synced was during code pushes.  But for some reason or another our team run the Sync first if there are ever any issues in AX.  Regardless if it is needed or not so it would blow away the index and the time it takes to remove an index would make it take longer for the sync...

  • Suggested answer
    Sebastian Mankowski Profile Picture
    305 on at

    Hi Glen...

    I believe there is no simple way to do it - as AX will continuously drops an index during synchronization. The only way that comes on top of my mind is to overwrite Application.dbSynchronize method and recreate an index after synchronization is completed. So using Sukrut code your solution would look like that:

    public boolean dbSynchronize(
        TableId         tableId                 = 0,   // 0 = all tables, non-zero is a valid table handle
        boolean         syncAsNeeded            = true,  // true = objects touched in the AOT, false = unconditional synchronize
        boolean         continueOnError         = true,
        boolean         showProgress            = true,  // true = report all problems, but throw only after all tables are synchronized, false = stop synchronize after first error/problem
        container       checkSyncTables         = conNull(), // [0] all tables or [x, y, z, ...] for 1 or more tables
        boolean         createAllIndexes        = true,
        boolean         useLockForSingleTable   = true)

    {

    ....

    // Your code start here -->

    str sql;
    Connection conn;
    SqlStatementExecutePermission permission;

    // Your code ends here <--

    ....

    ....

    ok = super(tableId, syncAsNeeded, continueOnError, showProgress, checkSyncTables, createAllIndexes, useLockForSingleTable);

    // Your code starts here -->

    if (ok && (tableId == tableNum(AccessRightsList) || tableId == 0))

    {

    // Create index statement

           sql = "";

           permission = new SqlStatementExecutePermission(sql);

           permission.assert();

           conn = new Connection();

           // the permissions needs to be reverted back to original condition.

           Statement statement = conn.createStatement();

           statement.executeUpdate(sql);      

           statement.close();

           CodeAccessPermission::revertAssert();

    }

    // Your code ends here <--

    ....

    ....

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans