10 April 2017

Specifics of update_recordset crossCompany in AX 2012

Have you ever tried to run update_recordset crossCompany statement?
Yes, it is possible. There are only 5 methods in standard AX code with such statement, but it can be very useful for data update jobs in multi company environment.

Tables:
TaxTransGeneralJournalAccountEntry.moveTaxForeignKeyToTaxTrans()
RetailLoyaltyConflictCard.migrateConflictCards()

Classes:
ReqDemPlanForecastChangeTracker.applyAllChanges()
ReleaseUpdateDB63_HRMMinor.updatePositionForecastBudgetAcctLine()
ReleaseUpdateDB63_HRMMinor.updatePositionForecastCompGroupRefPoint()

You must disable update method, database log and alerts, otherwise compiler will throw an error, for example:
transTable.skipDataMethods(true);
transTable.skipDatabaseLog(true);
transTable.skipEvents(true);
update_recordSet crossCompany transTable
setting loyaltyCardId = conflictCard.NewCardNumber
    where transTable.loyaltyCardId == conflictCard.CardNumber
       && transTable.dataAreaId == conflictCard.Company;
If you are still not convinced, then there is another example below.