AX – D365FO – Using update_recordset with CrossCompany statement

If you have tried to use Update_recordset with CrossCompany option you’ll probably have faced this error : “Cannot update multiple records in yourTable(yourTable).
Cross company update_recordset operation should skip database logging.”

The reason is because you have to disable database logging before to proceed

To solve this issue you must use these methods :




Follow this code :

TaxTrans        taxTrans;
TaxBook         taxBook;
TaxBookSection  taxBookSection;

taxBook = TaxBook::findByTaxBookId('ACQCEE');
taxBookSection = TaxBookSection::findByTaxBookSection('ACQCEE');

if(taxBook && taxBookSection)
   taxTrans.skipDataMethods(true); //Use these methods to solve the issue
   taxTrans.skipDatabaseLog(true); //Use these methods to solve the issue
   taxTrans.skipEvents(true);      //Use these methods to solve the issue

   update_recordset crossCompany  taxTrans
   setting  TaxBook = taxBook.recId, 
            TaxBookSection = taxBookSection.RecId
   where taxTrans.TaxBook == 0
   &&    taxTrans.Voucher like 'ACEE21*'
   &&    TaxTrans.dataAreaId == 'DAT';

   info(strFmt(" %1 rows updated", int2Str(taxTrans.RowCount())));


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s