Transaction scope is expected from the caller of method SalesTable.insert

Hi All,

As a requirement i have to create sales order through batch if the order for related agreement is not available. For this i have wrote the below error where i am getting app.ttsLevel == 0 error.

Although I am using ttsbegin and commit in my code but when it’s going to Sales Table Insert there the value is getting null and the below piece of code through this error . Same code in working fine for Runnable class but when writing it in a click or other class through error.

Here is my code.

while select CRMSalesOrderCreationStaging
{

Info(strFmt("%1",appl.ttsLevel()));
agreementNum = CRMSalesOrderCreationStaging.CRMAgreementNumber;

if(!Salestable::findCRMAgreement(agreementNum))
{
salesTable.SalesId = ‘SO-’+agreementNum;
salesTable.initValue();
salesTable.CRMAgreementNumber = agreementNum;
salesTable.CustAccount = CRMSalesOrderCreationStaging.CustAccount;

salesTable.initFromCustTable();
ttsbegin;
salesTable.insert();
info(strFmt(“Created SalesOrder %1”, salesTable.SalesId));
ttscommit;
}
else
{
info("Update Sales Order Number ");
}

}

Which value is null?

Are you sure that the error is thrown from insert() called from the code above? Couldn’t it be called from somewhere else?

You said it worked fine when running from a runnable class, but isn’t it what your screenshot shows? It failed there too.

By the way, please don’t attach tags for AX 2012 if your question isn’t about AX 2012.

Hi Martin,

It was a Synchronization issue. It’s working fine after Full system sync .

Thanks for support.