D365/AX7: Create A Batch Job Using SysOperation Framwork

  1. Create a data contract class  
    
    [DataContract]
    class AcxSysOperationContract
    { 
    PurchId purchId; 
    [DataMemberAttribute("PurchId")]
    public PurchId parmpurchId(PurchId _purchId = purchId)
    {
    purchId = _purchId;
    return _purchId;
    }
    
    }
  2. Create a service class where you will place your custom business logic
    
    class AcxSysOperationService
    {
    public void operation(AcxSysOperationContract _dataContract)
    {
    info(_dataContract.parmpurchId());
    //your business logic
    }
    
    }
  3. Create a controller class
    
    class AcxSysOperationController extends SysOperationServiceController
    {
    public static void main(Args args)
    {
    AcxSysOperationController sysOperationController = new AcxSysOperationController();
    sysOperationController.parmClassName(classStr(AcxSysOperationService));
    sysOperationController.parmMethodName(methodStr(AcxSysOperationService, operation));
    sysOperationController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    sysOperationController.startOperation();
    }
    
    }

3 thoughts on “D365/AX7: Create A Batch Job Using SysOperation Framwork”

  1. Thanks for the post. Just wanted to let you know there is one error (might be typo) in contract class. ‘purchId’ should be return in place of ‘_purchId’.

  2. Thanks for sharing. I have a question:
    What if a Form Caller wants to use a SysOperation in order to take advance of the UI/Contract framework for prompting a dialog, but it wants to retrieve a populated Temp Table from the service. The startOperation does not return value, and i can’t find the current instance of the service to invoke any other method to retrieve my DataMember like method.
    It seems my Tmp Datasource in my Form Caller has to be an argument to DataContract and Service is responsible to refresh it? What a long way workaround to put my artifacts to talk inside the same application! Shouldn’t the framework make things simpler?

Leave a Reply