Update cross reference in batch in Dynamics AX 2012

The information in this post is based on Dynamics AX 2012 R3. It may or may not be valid for other versions.

An updated cross reference is an invaluable tool for some tasks such as debugging and searching for where specific elements are used in Dynamics AX. Unfortunately, it takes so long to update that it is done very infrequently on many projects – often it is up to the development lead to do it and let his or her session hang overnight. If it crashes or gets interrupted in the meantime it’s all over again.

Fortunately, running it as a batch job is very simple. Assuming you want to clear (truncate) any existing data in the cross reference tables and update the cross reference for all elements (full tree), just run this little job:

static void CrossRefUpdateBatch(Args _args)

    xRefUpdateIL::updateAllXref(true, false, true);
    info("Done, cross reference update batch job created.");

It should be pretty self-explanatory. The three boolean parameters for the updateAllXref method just means to update full tree, not update selectively (as we want full tree), and to update table relations as well. You should see the job complete very quickly, already giving you a hint that the actual task of updating has been passed to the batch processor so you don’t have to wait for it 🙂

Open up the batch jobs form and verify that a batch job with the description “Update xref for complete AOT” has been created. In fact, it’s probably already running. If you want it to repeat automatically, say, once a week, you can just edit the batch job to fit your needs. Or, you can just run the above code snippet whenever you need to update the cross reference again.

Notice that the batch job is created to run in the empty batch group by default. If you need it to be executed in a different group or on a specific AOS you may need to do some tweaking.

You can close down the AX client and go home, just make sure the batch server AOS is not restarted until the batch job has finished 😉 – depending on your hardware, a full tree cross reference update typically takes between 8 and 12 hours.