How to get Args.caller in Service class of SysOperation Framework.

Hi all.

I’m having an issue with AX2012.
I’m making process using SysOperation Framework as follows.

  1. selecte multiple line on a form.
  2. clicke button to process.
  3. show dialog then input some criteria and click ok button.
  4. startOperation in inherited SysOperationServiceController.
  5. main process in inherited SysOperationServiceBase.
    here, I want to process with only selecting line number of times.

I thought, it’s ok to using MultiSelectionHelper. But I couldn’t pass the args.caller().
First, I put the parmCaller() on Contract class. But It couldn’t get any value on Service Class.
It doesn’t seems get value if it doesn’t add DataMemberAttribute on method. So I added it on method.
But error occurd while execute.
Second I struggled to add Args on Service class, but error occured.

Does Anyone know how to pass the Args.Caller from Controller class to Service class?
Is it possible?

You can call args.caller() in main() method of the controller class (or pass args to another method and do it there, of course). Then fill the data contract, where you can use either primitive types or other data contracts. Forms clearly don’t belong to either category, therefore you have to extract data and put them to the data contract already in the controller.

Hi Martin, thanks for reply.

I tried as follows so far.

  1. made parmCaller() method in contract class.

  2. got args.caller() in main() method of controller class and put the value to parmCaller() method in contract class.

  3. got args.caller() via parmCaller() in service class defined contract class as argument. but args.caller was null.

  4. [contract]
    public FormRun parmCaller(FormRun _caller = caller)
    {
    caller = _caller;
    return caller;
    }

  5. [controller]
    public static void main(Args _args)
    {
    SysOperationControllerTest controller;
    SysOperationContrctTest contract;

controller = new SysOperationControllerTest();
contract = controller.getDataContractObject();

contract.parmCaller(_args.caller());

controller.startOperation();
}

protected void new()
{
super(classStr(SysOperationServiceTest),
methodStr(SysOperationServiceTest, Test), ← here
SysOperationExecutionMode::Synchronous);
}

  1. [service]
    public void Test(SysOperationContrctTest _contract)
    {
    FormRun caller;

caller = _contract.parmCaller(); ← caller is null
}

after click ok button, service class is started. only defined method in new() of controller class.
I still don’t get caller. How can I do this?

As I already tried to explain, FormRun can’t be used in data contracts. Please refer to Using Data Contracts in X++ [AX 2012] for details about types you can use.

OK I got you. Thanks Always.

If it’s all you need, please mark my answer as the verified solution.