Dynamics AX Blog - Dynamics AX 2012 - sysoperation-framework - Microsoft Dynamics AX (Axapta) - Page 1
In recent years, i spent a lot of time in developing in the environment of Microsoft Dynamics AX (formerly Axapta). During this time i created a lot of code, from which I could imagine, that it might be very useful for other AX developers too. But I will present also tips and tricks round the powerful ERP system.
Subscribe to RSS feed of this categoryRSS-Feed of this version
SysOperation-Framework: Force Batch ProcessingIf you want to make sure that a function implemented via the SysOperation-framework is always executed via batch processing, you can set the SysOperationExecutionMode to ScheduledBatch (e.g. via the MenuItem of the controller - see here). If this is a function that requires a user dialog, however, the problem is that the "Batch" tab is displayed by default and, for example, the "Batch" check box is not activated there. Of course you can activate this checkbox by including a call to parmBatchExecute() in the UIBuilder: public void build() { super(); this.controller().batchInfo().parmBatchExecute(this.controller().parmExecutionMode() == SysOperationExecutionMode::ScheduledBatch); } |
SysOperation-Framework: Usage data per MenuItemImagine you have a function build using the SysOperation framework that can be called at different places in the system, and you want to make sure that these calls do not share the same usage data. In such a case you could create two (or more) MenuItems and override the method lastValueDesignName() of the controller as follows. This will store separate usage data for each MenuItem. protected IdentifierName lastValueDesignName() { IdentifierName ret; ret = super(); if (this.parmArgs() && this.parmArgs().menuItemName()) { ret = this.parmArgs().menuItemName(); } return ret; } |
Create batch job with multiple tasks by codeThe code snippets below show how to create batch jobs using the BatchHeader class. Examples for a RunBaseBatch constructstatic void createBatchWithMultipletasks(Args _args) { BatchHeader batchHeader; Tutorial_RunbaseBatch batchTask1, batchTask2, batchTask3; //create batch header batchHeader = BatchHeader::construct(); batchHeader.parmCaption("Example of a batch job with multiple tasks"); //create instances of the classes to use as batch tasks batchTask1 = Tutorial_RunbaseBatch::construct(); batchTask2 = Tutorial_RunbaseBatch::construct(); batchTask3 = Tutorial_RunbaseBatch::construct(); //add the batch tasks to the batch header batchHeader.addTask(batchTask1); batchHeader.addTask(batchTask2); batchHeader.addTask(batchTask3); //save the batch batchHeader.save(); } |
SysOperation-Framework: Simplest class constructThe code below is the simplest way to implement a function using the SysOperation framework. Without DataController, Dataprovider and UIBuilder. Only with a service class and a MenuItem. Serviceclass TutorialSysOperationSimpleService extends SysOperationServiceBase { } The runService() method is the actual service method. The SysEntryPointAttribute attribute controls that no further authorization checks are necessary. [SysEntryPointAttribute(false)] public void runService() { info("Done"); } |
SysOperation-Framework: Enable batch processing by defaultIf you want to activate batch processing by default for a function implemented via the SysOperation framework, you can do this by modifying the UI Builder like in the following example. public void build() { super(); this.controller().batchInfo().parmBatchExecute(NoYes::Yes); } The code activates the checkbox Batch processing in the Batch tab. |
SysOperation framework: Pass selected records from a temporary tableIn the following scenario, all records of a temporary table are to be passed to a SysOperation construct. For that we need:
Controllerclass TutorialSysOperationController extends SysOperationServiceController { } |
|
|
|
|
|
|
If you want to control the SysOperationExecutionMode and/or the server method to be executed via the MenuItem in a SysOperation construct, you can control this via the properties of the MenuItem.
Scenario: Without own controller
The following two MenuItems show how to set the properties for them:
This MenuItem calls the runService() method of a service class and sets the SysOperationExecutionMode to Synchronous: