Cannot select a record for update when the transaction is not started on the user connection attached. You need to begin transaction on the user connection first. in d365F&O

 Hi Viewers,

I have recently faced this error while working on the standard report. In standard DP class temp table has userconnection. So whlie updating I got below error.

Cannot select a record for update when the transaction is not started on the user connection attached. You need to begin transaction on the user connection first. in d365F&O.


To fix this use  <TmpTablebufferName>.ttsBegin();  <TmpTablebufferName>.ttscommit();


Example:


        VendAccruedPurchasesTmp vendAccruedPurchasesTmp;

  VendAccruedPurchasesTmp.ttsbegin();

        while select  forupdate VendAccruedPurchasesTmp

                where VendAccruedPurchasesTmp.ItemId != ''

                && 

                VendAccruedPurchasesTmp.AVACIProcurementCategory == ''

            //join inventItemGroupItem

            //    where inventItemGroupItem.ItemId == vendAccruedPurchasesTmpLoc1.ItemId

            {

                mainAccountPosition     = 0;

            searchParameters        = InventPostingItemLedgerDimensionParameters::newFromParameters(InventAccountType::PurchReceipt, VendAccruedPurchasesTmp.ItemId);

                ledgerDimension         = InventPosting::itemLedgerDimensionFromParameter(searchParameters);

                mainAccountNum          = LedgerDimensionFacade::getMainAccountIdFromLedgerDimension(ledgerDimension);

            mainAccountPosition     = strScan(VendAccruedPurchasesTmp.AVIFinancialDimension, "-", mainAccountPosition, strLen(VendAccruedPurchasesTmp.AVACIFinancialDimension));

            dimensionDisplayValue   = subStr(VendAccruedPurchasesTmp.AVIFinancialDimension, mainAccountPosition, strLen(VendAccruedPurchasesTmp.AVCIFinancialDimension) - mainAccountPosition);

              

            VendAccruedPurchasesTmp.AVIMainAccountId       = mainAccountNum;

            VendAccruedPurchasesTmp.AVIFinancialDimension  = mainAccountNum + dimensionDisplayValue + "-";

            VendAccruedPurchasesTmp.doUpdate();

                       }

        VendAccruedPurchasesTmp.ttscommit();


Comments

Popular posts from this blog

Records to include in SSRS Report With UI Builder class

Multi select lookup in UI Builder class in D365F&O through x++ code.