Источник:
http://dynamicsaxhints.blogspot.com/...recordset.html
==============
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.
static void updateRecordSetCrossCompany(Args _args)
{
CustTable custTable;
PaymTermId oldPaymTermId =
'Net10', newPaymTermId =
'Net11';
// original state
while select crossCompany dataAreaId,
count(RecId)
from custTable
group by custTable.dataAreaId
where custTable.PaymTermId == oldPaymTermId
{
info(
strFmt(
'Original: company %1 has %2
customers with PaymTermId %3.',
custTable.dataAreaId, custTable.recId, oldPaymTermId));
}
// update
custTable.skipDatabaseLog(
true);
custTable.skipDataMethods(
true);
custTable.skipEvents(
true);
update_recordSet crossCompany custTable
setting PaymTermId = newPaymTermId
where custTable.PaymTermId == oldPaymTermId;
// new state
while select crossCompany dataAreaId,
count(RecId)
from custTable
group by custTable.dataAreaId
where custTable.PaymTermId == newPaymTermId
{
info(
strFmt(
'New: company %1 has %2 customers with PaymTermId %3.',
custTable.dataAreaId, custTable.recId, newPaymTermId));
}
}
The job results are:
Источник:
http://dynamicsaxhints.blogspot.com/...recordset.html