static void crossCompanyUpdate(Args _args) { CustTable custTable; CustGroup custGroup; PaymTermId oldPaymTermId = 'Net10', newPaymTermId = 'Net11'; ttsBegin; // find all companies with oldPaymTermId while select crossCompany custGroup group by custGroup.dataAreaId where custGroup.PaymTermId == oldPaymTermId { changeCompany(custGroup.dataAreaId) { // disable update method custTable.skipDataMethods(true); // set newPaymTermId update_recordSet crossCompany custTable setting PaymTermId = newPaymTermId where custTable.PaymTermId == oldPaymTermId; } } ttsCommit; } |
Solution
There is no compile or runtime error, but records are updated only in one company. Table variable must be set to
null
within changeCompany
statement, marked in orange below:static void crossCompanyUpdate(Args _args) { CustTable custTable; CustGroup custGroup; PaymTermId oldPaymTermId = 'Net10', newPaymTermId = 'Net11'; ttsBegin; // find all companies with oldPaymTermId while select crossCompany custGroup group by custGroup.dataAreaId where custGroup.PaymTermId == oldPaymTermId { changeCompany(custGroup.dataAreaId) { custTable = null; // disable update method custTable.skipDataMethods(true); // set newPaymTermId update_recordSet crossCompany custTable setting PaymTermId = newPaymTermId where custTable.PaymTermId == oldPaymTermId; } } ttsCommit; } |
custTable = null ;)
ReplyDeleteIt is correct, thank you for the comment! :-)
DeleteMy ideas is static void crossCompanyUpdate(Args _args)
ReplyDelete{
CustTable custTable;
CustGroup custGroup;
PaymTermId oldPaymTermId = 'Net10', newPaymTermId = 'Net11';
ttsBegin;
// find all companies with oldPaymTermId
while select crossCompany custGroup
group by custGroup.dataAreaId
where custGroup.PaymTermId == oldPaymTermId
{
changeCompany(custGroup.dataAreaId)
{
custTable = null;
// disable update method
custTable.skipDataMethods(true);
// set newPaymTermId
update_recordSet custTable
setting PaymTermId = newPaymTermId
where custTable.PaymTermId == oldPaymTermId;
}
}
ttsCommit;
} Please check that code. I can't check because I have an AX 2009 version system.
You are absolutely right, thank you for the comment! :-)
Delete