ERROR: Cannot call NEXT, update(), or delete() on buffer - Microsoft Dynamics 365 Vietnam

Microsoft Dynamics 365 Vietnam

Song Nghia - Microsoft Dynamics 365 Vietnam

Breaking

Tuesday, April 9, 2019

ERROR: Cannot call NEXT, update(), or delete() on buffer

Nghia Song

Tel - WhatsApp: +84967324794

Email: songnghia.uit@gmail.com

This is a very basic concept. If you get the following error:
"Cannot call NEXT, update(), or delete() on buffer where data is selected or inserted in another transactionscope."
It means that the record selected has table caching activated, such as ‘NotInTTS’ and that you attempted to, for example run code like the following:
//wrong
select firstonly forupdate aRecord;
ttsbegin;
aRecord.delete();
ttscommit;
It is important in general and necessary for cached tables to begin the transaction scope before selecting the record for update. And so, even for tables that do not have caching enabled, it is strongly discouraged to call NEXT, update(), or delete() on a buffer outside of the transaction scope it was selected in.
//good
ttsbegin;
select firstonly forupdate aRecord;
aRecord.delete();
ttscommit;