D365 X++ public void confirmByClosingSpecial boolean isRetry = false; try ttsbegin; if isRetry thisreLoadConsInvo
这个错误是因为在更新consInvoice之前没有选择要更新的数据。
解决方法是在更新之前选择要更新的数据。可以使用select forupdate语句来选择要更新的数据。例如:
CustVendConsInvoice consInvoiceForUpdate; select forupdate consInvoiceForUpdate where consInvoiceForUpdate.RecId == consInvoice.RecId; consInvoiceForUpdate.Status = CustVendConsInvoiceStatus_JP::Confirmed; consInvoiceForUpdate.CustVendConsInvoice_JP::setInvoiceAmount(); // 更新其他字段 consInvoiceForUpdate.update();
请注意,select forupdate语句应该在ttsbegin之前执行,以确保选中的数据在事务中被锁定。
另外,还要确保在更新之前检查consInvoice是否为空,以防止空引用错误。可以使用以下代码进行检查:
if (consInvoice) { // 更新代码 } else { throw error("ConsInvoice is null");
原文地址: https://www.cveoy.top/t/topic/ivW0 著作权归作者所有。请勿转载和采集!