Batch Processing in Dynamics AX 2012 Using SysOperation Framework

by | Mar 27, 2017 | 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 (992 downloads)

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

may

28may1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Designing the Software Collaboratively

june

02jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Conference Room Pilots

03jun10:00 am10:30 amWhy Levridge Grain? Streamlining Sales Contracts

04jun11:00 am12:00 pmConfab With Stoneridge - Livestream - Customer Insights

04jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Dealing with Challenges Mid-Project

09jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Customizations vs Configurations and How You Manage Them

10jun10:00 am11:00 amOn the Job with Dynamics 365 - Manufacturing Buyer

11jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Data Migration - Early and Often

15jun(jun 15)9:00 am16(jun 16)4:00 pmDynamics 365 Finance and Supply Chain Management Training for AX 2012 Developers

16jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Environment Management and Deployments

17jun10:00 am10:30 amWhy Levridge Grain? Best Practices for Managing Load Orders for Grain Processors

17jun12:00 pm1:00 pmMobilizing an efficient, streamlined AP department with AP Automation

17jun2:00 pm3:00 pmGuide for B2B Businesses: Tackling Supply Chain Optimization and Customer Experience Challenges

18jun11:00 am12:00 pmConfab with Stoneridge - Livestream - Enterprise Asset Management and Preventative Maintenance

18jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Testing - Definition and Activities

23jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Training for All

24jun10:00 am11:00 amOn the Job with Dynamics 365 - Manufacturing Production Manager

25jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Going Live

30jun1:00 pm1:30 pmHow to Implement Microsoft Dynamics: Hypercare

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