Recently I posted a Trick to create a display method on sys Tables using overlaying. In further researches, due to necessity, I bumped into a new and more robust way of doing the same.
The purpose of this post is to explain a possibility to facilitate the manipulation of Table Methods on Augmented classes.
Augmented classes are necessarily Final classes defined by the use of the Attribute ExtensionOf on its declaration, in my example I’m augmenting the Table ProjForeCastOnAcc.
This allows us to interact with the class as if it were the actual table, So we have access to fields, methods, and properties from the original table.
I created this new display method on it, notice that at line ‘8’ of the following code, I’m mentioning one field from the original table by using the reserved word “this”, although the current object is not the actual table. All fields, methods, and properties from the original table can be accessed this way as if we were in the actual object.
X++ Executing Table methods from Augmented classes
This feature allows us to access these new methods as if they were located in the original table wherever a buffer is created. The next code is a non-related Class making use of the new Display Method on the Augmented class, notice line 12 of the following code:
Form usage of display methods from Augmented classes
The way of mentioning the extended methods on Forms is still the same as in the old trick. You must have the correct DataSource, then insert the full name of the Augmented Class together with the desired display method name to the field’s property “Data Method”, like this:
- DataSource: ProjForecastOnAcc
- DataMethod: ProjForecastOnAcc_Extension::grantName
If done correctly, this solution should work without any issues.
Hope it might be helpful,