AX 2012 - Update must be performed inside a transaction
Hi Readers,
Many times you might have seen below error while you were updating or inserting data using X++.
Error:
Update must be performed inside a transaction
Solution:
The solution for the above error is you must keep your updating or inserting code into ttsBegin and ttsCommit.
Syntax:
ttsBegin;
// Your_Code
ttsCommit;
Example:
Copy code from below:
Comment below if this solution helps you to resolve your issue...
Author:
Chirag Gupta
Microsoft Dynamics 365 AX Technical Consultant at IBM Bangalore
Date:
24-Sep-2019
Happy Learning !!
Many times you might have seen below error while you were updating or inserting data using X++.
Error:
Update must be performed inside a transaction
Solution:
The solution for the above error is you must keep your updating or inserting code into ttsBegin and ttsCommit.
Syntax:
ttsBegin;
// Your_Code
ttsCommit;
Example:
Copy code from below:
// Code written by Chirag Gupta
static void updateRebateData(Args _args)
{
PdsRebateTable pdsRebateTable;
PdsRebateAgreement pdsRebateAgreement;
PdsRebateAgreementLine pdsRebateAgreementLine;
int counter = 0;
while select forUpdate pdsRebateAgreementLine
join pdsRebateAgreement
where pdsRebateAgreementLine.RebateAgreementRefRecId == pdsRebateAgreement.RecId
&& pdsRebateAgreement.PdsRebateType == 'Ad-Hoc'
&& pdsRebateAgreement.PdsCustRebateRelation == 'C00489'
&& pdsRebateAgreementLine.RebateAmtType == PdsRebateAmtType::Percentage
&& pdsRebateAgreementLine.dataAreaId == curext()
{
if (pdsRebateAgreementLine)
{
ttsBegin;
pdsRebateAgreementLine.RebateValue = 11;
pdsRebateAgreementLine.doUpdate();
counter++;
ttsCommit;
}
}
info(strFmt("%1", counter));
info("Done");
}
static void updateRebateData(Args _args)
{
PdsRebateTable pdsRebateTable;
PdsRebateAgreement pdsRebateAgreement;
PdsRebateAgreementLine pdsRebateAgreementLine;
int counter = 0;
while select forUpdate pdsRebateAgreementLine
join pdsRebateAgreement
where pdsRebateAgreementLine.RebateAgreementRefRecId == pdsRebateAgreement.RecId
&& pdsRebateAgreement.PdsRebateType == 'Ad-Hoc'
&& pdsRebateAgreement.PdsCustRebateRelation == 'C00489'
&& pdsRebateAgreementLine.RebateAmtType == PdsRebateAmtType::Percentage
&& pdsRebateAgreementLine.dataAreaId == curext()
{
if (pdsRebateAgreementLine)
{
ttsBegin;
pdsRebateAgreementLine.RebateValue = 11;
pdsRebateAgreementLine.doUpdate();
counter++;
ttsCommit;
}
}
info(strFmt("%1", counter));
info("Done");
}
Comment below if this solution helps you to resolve your issue...
Author:
Chirag Gupta
Microsoft Dynamics 365 AX Technical Consultant at IBM Bangalore
Date:
24-Sep-2019
Happy Learning !!
Comments
Post a Comment