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 (1225 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

march

03mar10:00 am10:30 amThe Modern Manufacturer - MRP vs. MPS – What, When and How

03mar2:00 pm2:30 pmLot Management Best Practices for Batch Manufacturers

10mar10:00 am10:30 amEnhancing the Customer Experience and Driving More Business with Dynamics 365 Customer Service

10mar2:00 pm2:30 pmThe Five Steps to Managing Sales Tax

11mar11:00 am12:00 pmConfab with Stoneridge - Livestream - Power Apps Component Framework Power Hour

17mar10:00 am10:30 amThe Modern Manufacturer: Pro Tips for your Finance Team

24mar10:00 am10:30 amUnlock the Potential of Digital Marketing with Dynamics 365 Marketing

25mar11:00 am12:00 pmConfab with Stoneridge - Livestream - The Four Keys to Choosing the Best ERP or CRM Solution

31mar10:00 am10:30 amThe Modern Manufacturer: Keys to Reporting Success

31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central

april

31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central

07apr10:00 am10:30 amBoost Seller Productivity and Close More Business with Dynamics 365 Sales

07apr2:00 pm2:30 pmEnsuring Quality for Batch Manufacturers

08apr11:00 am12:00 pmConfab with Stoneridge - Livestream - Jumping into the Deep End of the Data Lake

14apr10:00 am10:30 amThe Modern Manufacturer: Cost Accounting in D365

21apr12:00 pm1:00 pmGetting Started with Barcode Scanners and WMS Apps for Business Central

22apr11:00 am12:00 pmConfab with Stoneridge - Livestream - Moving from Manual to Automated with Strategic Automation Strategies

28apr10:00 am10:30 amThe Modern Manufacturer: Best Practices for Inventory Turn

28apr12:00 pm1:00 pmPower Up Microsoft Dynamics by Automating Budgeting, Dashboarding and Reporting

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