Tuesday 15 March 2016

Dynamics AX7 Development 6–Adding Delegates for Customised Code in Higher Package

Dynamics AX is split into multiple models the main ones are as follows; Application suite, Application Foundation and Application Platform.
2016-01-20_1256
If you look at some of the debendencies you see how the organization of model affects the assemblies (how it is compiled).
In some cases you have to modify the Foundation or the Platform. The issue with that is you are unable to reference code sitting in a higher package (model). In short a higher model can take dependencies and access elements in a lower model but not the other way around.
To get around this limitation you have to use a delegate method. Below is an example of a delegate. The PrintMgmtDocType has a method to get the default report form.
2016-01-29_0612
See how the delegate method is called from the Foundation and uses an EventHanderResult to pass around the result.
2016-01-29_0610
The delegate method doesnt have to have any code. It is there to allow other methods to subscribe to it.
2016-01-29_0611
Now this is the calls in the Suite. Notice how to subscribe by adding the SubscribesTo attribute.
2016-01-29_0623
Refer to the Microsoft Wiki. It has some really good examples.

No comments:

Post a Comment