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();
    }
    
    }

Leave a Reply