Greetings everyone,
I am trying to understand sysoperation frame work on d365FO and want to create a batch proces after any event happens.
I wrote service,controller and datacontract classes. For this system i dont want to show any dialog to user. I want to pass parameters from code.
Here is my service classes and controllers.
class MyAsyncSysOperationController extends SysOperationServiceController
{
protected void new(IdentifierName _methodName)
{
super(classStr(MyAsyncSysOperationService),_methodName,SysOperationExecutionMode::Asynchronous);
}
public static MyAsyncSysOperationController construct(IdentifierName _methodName,SysOperationExecutionMode _executionMode = SysOperationExecutionMode::Asynchronous)
{
MyAsyncSysOperationController controller;
controller = new MyAsyncSysOperationController(_methodName);
controller.parmExecutionMode(_executionMode);
return controller;
}
public static void main(Args _args,IdentifierName _methodName)
{
MyAsyncSysOperationController controller;
controller = MyAsyncSysOperationController::construct(_methodName);
switch(_methodName)
{
case methodStr(MyAsyncSysOperationService,sendPurchLine):
MyPurchLineDC line;
PurchLine purchLine;
purchLine = _args.record();
line = controller.getDataContractObject();
line = MyPurchLine::initFromPurchLine(purchLine);
break;
default:
Info("");
}
controller.parmArgs(_args);
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);
controller.startOperation();
}
}
class MyAsyncSysOperationService extends SysOperationServiceBase
{
public void sendPurchLine(MyPurchLineDC _purchLine)
{
// sending data to message queue
}
public void sendSalesLine(MySalesLine _salesLine)
{
// sending data to message queue
}
public void sendCustTable(MyCustVend _custVend)
{
// sending data to message queue
}
}
public static MyPurchLineDC initFromPurchLine(PurchLine _purchLine)
{
MyPurchLineDC line = new MyPurchLineDC();
// fill data here
return line;
}
When i call my datacontract init method on my service class method sendPurchLine(MyPurchLineDC _purchLine) becomes empty and cant see any data on _purchLine.
line = controller.getDataContractObject();
line = MyPurchLineDC::initFromPurchLine(purchLine);
Other hand if i fill data at controller class insted of using new everything works fine.
line = controller.getDataContractObject();
line.parmPurchId(purchLine.PurchId);
line.parmLineNum(purchLine.LineNumber);
I know object referance completely changes when i call "new" but is there any way to re set datacontract on the controller. Actuly i am asking is there any way to setDataContractObject();
Also is there anyway to pass args from controler to service class.
Hope could explained my self
Thanks for answers.