Batch Processing in Dynamics AX 2012 Using SysOperation Framework

by | Updated January 2, 2018 | Development, Dynamics AX

In Microsoft Dynamics AX 2012, SysOperation framework replaced RunBase framework to support the batch processing functionality. Going forward, SysOperation framework is recommended for writing custom business logic that requires batch processing functionality, over the deprecated RunBase framework.

The RunBase framework defines coding patterns that implement these requirements. The SysOperation framework provides base implementations for many of the patterns defined by the RunBase framework. Another great thing is SysOperation framework simplified the pack / unpack of variables that was additional work in the RunBase framework, taking advantage of the Attributes feature introduced with AX 2012. For a detailed comparison between SysOperation and RunBase framework, refer to Microsoft Dynamics AX 2012 White Paper: Introduction to the SysOperation Framework.

SysOperation framework allows application logic to be written in a way that supports running operations interactively or via the Microsoft Dynamics AX batch server. It implements the MVC (Model–View–Controller) design pattern, with the isolation of Parameters (Model), Dialog (View) and Service (Controller), for the code that’s executed.

The key objects of the framework are defined below:

Service: Service class extends from the SysOperationServiceBase class and contains the business logic for the batch operation. Developers often tend to add the business logic in controller classes, which violates the Single responsibility principle.

Data Contract: Data contract class is the model class defining attributes needed for batch operations. These attributes are provided by the user, in a dialog. DataContractAttribute attribute is needed for the class and the properties methods requires DataMemberAttribute attribute.

Controller: Controller class extends from the SysOperationServiceController class. It holds information about the batch operation like execution mode, show dialog or progress bar etc. and directs the batch operation.

UI Builder: UI Builder class extends from SysOperationAutomaticUIBuilder class and is used for adding custom behavior to dialog / dialog fields dynamically constructed by the SysOperation framework.

In this blogpost, I’ll cover three different scenarios (in a sequential manner) for creating batch operations using SysOperation framework classes – Service, Data Contract, Controller and UI Builder.

Scenario 1: Creating a simple batch operation

Project: SharedProject_SysOperation_SimpleBatchOperation.xpo

Creating a simple batch operation

Running batch operation

1. Controller Class

2. Service Class

3. Optional: Menu item

Type: Action menu item
Object type: Class
Object: SysOperationControllerClass

Scenario 2: Add user defined parameters for batch operation

Project: SharedProject_SysOperation_UserDefinedParmsBatchOpr.xpo

Add user defined parameters for batch operation

Add user defined parameters for batch operation

1. Controller Class

2. Service Class

3. Data Contract Class

4. Optional: Menu item

Type: Action menu item
Object type: Class
Object: SysOperationControllerClass

Scenario 3: Add custom validation to dialog fields

Project: SharedProject_SysOperation_UserParmsValidationBatchOpr.xpo

Scenario 3.1 – Validation failed:

Add custom validation to dialog fields - Validation Failed

Add custom validation to dialog fields - Validation Failed

Scenario 3.2 – Validation passed:

Add custom validation to dialog fields - Validation Passed

Add custom validation to dialog fields - Validation Passed

1. Controller Class

2. Service Class

3. Data Contract Class

4. UI Builder Class

5. Optional: Menu item

Type: Action menu item
Object type: Class
Object: SysOperationControllerClass

Download the project .xpo(s) to import here:

SharedProject_SysOperation.zip (1083 downloads)

Related Posts

  • In Dynamics AX 2012, there are times when batch jobs appear to be stranded in a waiting status.  When this happens, the cause can typically be a batch server or batch group…

  • Over on the AX Support site on MSDN, Daniel Durrer has taken the time to keep tabs on the latest builds for Microsoft Dynamics AX 4.0, 2009 and 2012.  I…

  • Batch transfer rules in Dynamics AX 2012 is a new framework giving you the ability to control the timing of when a document posts to the ledger. These rules determine…

3 Comments

  1. Craig Madsen

    I’m trying to do your first scenario, and I’m keying in the new() method, but when I try to enter the parm after the classStr method, my Intellisense only shows: options of “SysOperationServiceBase” and “SysOperationServiceController”. And if I key in “SysOperationServiceClass”, I get an error stating that this parm should be a “class”. We’re on Microsoft Dyanmics AX 2012 R3. Your examples look great, especially with the screen shots, and especially if I can make them work! Any help would be greatly appreciated!

    Thanks,

    Craig

  2. Brandon Carmichael

    Hi Craig,

    SysOperationServiceClass is a custom sample class we have created for demo purposes. It’s actually documented in Step 2 of the blogpost.

    Cheers,
    Brandon

  3. DM

    Awesome post. It helped!

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

september

02sep10:00 am10:30 amThe Modern Manufacturer - Cycle Count Management

02sep12:00 pm12:30 pmBest Practices for Work Order Planning and Routing for Field Service Companies

09sep10:00 am11:00 amWhat is Levridge? An Overview of the Ultimate Ag Solution

09sep12:00 pm12:30 pmOverview of Microsoft Promotion for NAV and GP Clients

10sep11:00 am12:00 pmConfab with Stoneridge - Livestream - Field Service Comparisons

16sep10:00 am10:30 amThe Modern Manufacturer - Product Lifecycle Management

16sep12:00 pm12:30 pmHow to Upgrade to Dynamics 365 Finance and Operations: Examining Custom Code and ISV Implications

16sep2:00 pm2:30 pmScheduling and Dispatching for the Modern Field Service Company

23sep12:00 pm1:00 pmDynamics 365 Business Central Wave 2 Release Preview - An Overview of the Most Exciting New Features Coming in October

24sep11:00 am12:00 pmConfab with Stoneridge - Livestream - The Modern Workplace: Teams, Sharepoint, Outlook, Office, and AI Integration

30sep10:00 am10:30 amThe Modern Manufacturer - Return Management

30sep12:00 pm12:30 pmEmpowering Your Field Service Technicians with a Mobile Solution

october

07oct12:00 pm1:00 pmThe Three Paths to Business Central from Dynamics GP

08oct11:00 am12:00 pmConfab with Stoneridge - Livestream - The Vision and Strategy of Microsoft Business Systems

14oct10:00 am10:30 amThe Modern Manufacturer - Complex Cost Modeling

14oct12:00 pm12:30 pmGenerating Custom Inspection or Process Forms

19octAll Day22Stoneridge Connect Fall 2020

22oct11:00 am12:00 pmConfab with Stoneridge - Livestream - Stoneridge Connect Recap

28oct10:00 am10:30 amThe Modern Manufacturer - Engineering Change Orders

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X