The Infolog

A blog of Dynamics AX development tips and tricks

Skip to: Content | Sidebar | Footer

Using the SysOperationFramework

11 January, 2016 (11:41) | Uncategorized | By: Howard Webb

As we all know that moving forward we should really be making better use of the SysOperationFramework. Having a little more time over xmas I decided to use the framework in a mod I was doing. The mod called for a new export to excel without using BIS.

There is a Microsoft white paper about using it but after reading it I found that the Art of creation have a blog post which is much easier to follow.

We develop using the framework in a similar way to the way we would develop an SSRS report (SSRS uses the framework in the background).

Firstly we need to create a contract class. This will store all of the user input and will be used by the framework to produce the dialog fields. Just like with a report we need to add the DataContractAttribute and then also all of the global variables that we will later create parm methods for it. A word of warning about this, if you add, remove or change any of these methods you’ll need to run a CIL or possibly even restart the AOS

 

 

Then for each of the variables we will need to create a parm method making sure to add DataMemberAttribute. Please note if you get your return data type correct it will handle all of the help text etc. for you but you can override them with additional attributes.

 

If we would like a query to be shown we need a few more methods in our class, first off a parm method for our query. Note the extra attribute AifQueryTypeAttribute in which we pass the packed query and the name of our query.

 

We also have set and get methods for our query:

 

 

 

With our contract class finished we can now move on to our data service class. We don’t have to do anything special with this class other than making sure that it runs on server and that the mothod you will run has the SysEntryPointAttribute and accepts in your contract class:

 

Add your business logic so your class does what you want and then we can create your menu item. The menu item needs to point to a controller class (in this instance I’ve used the system one but you could create a custom class and extend from the standard class. It also needs to accept the execution mode and finally in to the parameters you put the method you need to run.

 

 

With that done you are ready to test. Kick off a CIL and then you can open your menu item. You should get your dialog up, along with the parameters and the query ready to run, your user selections will be automatically packed and unpacked and you will have a batch tab: