I wish to create a reusable runnableClass which uses parameters to edit sales Orders. I started with a simple class with 1 parameter:
``
internal final class MyRunnableClass extends RunBase
{
RecId salesLineRecId1;
DialogField Dialog_salesOrderRecId;
public Object dialog()
{
Dialog dialog = super();
dialog.caption("Sales Order Update");
Dialog_salesLineRecId1 = dialog.addField(extendedTypeStr(RecId), "SalesLine 1 RecId");
return dialog;
}
public boolean getFromDialog()
{
salesLineRecId1 = Dialog_salesLineRecId1.value();
return super();
}
public static void main(Args _args)
{
MyRunnableClass script = new MyRunnableClass();
if(script.prompt())
{
script.run();
}
}
public void run()
{
SalesLine salesline;
ttsbegin;
select firstonly forupdate salesline
where salesline.recid == salesLineRecId1;
if (salesline.recid != 0)
{
salesline.CustomerRef = "Test";
salesline.doUpdate();
}
ttscommit;
}
}
``
When I run this, I receive the following error:
Microsoft.Dynamics.Ax.Xpp.ErrorException: 'Cannot select a record in Order lines (SalesLine).
The SQL database has issued an error.'
And the following stackTrace:
at Microsoft.Dynamics.Ax.MSIL.Interop.throwException(Int32 ExceptionValue, interpret* ip)
at Microsoft.Dynamics.Ax.MSIL.cqlCursorIL.EndFind(IntPtr table)
at Dynamics.AX.Application.MyRunnableClass.`run() in xppSource://Source/MyRunnableClass\AxClass_MyRunnableClas.xpp:line 69
at Dynamics.AX.Application.MyRunnableClass.run()
at Dynamics.AX.Application.MyRunnableClass.`main(Args _args) in xppSource://Source/MyRunnableClass\AxClass_MyRunnableClass.xpp:line 54
at Dynamics.AX.Application.MyRunnableClass.main(Args _args)
at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object[] parameters)
Does anyone know why I encounter this error?
When you get an error regarding database (like 'The SQL database has issued an error'), running the DB sync is always worth a try. It often solves the problem, or it'll tell you about another problem that prevents DB sync from doing its job.
Thanks for the tips!
Will look into the new framework, but a simple sync DB solved it indeed!
First of all, please try to synchronize the database.
By the way, note that there is a newer framework since AX 2012: SysOperation.
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156