#NAVdevTips 3: TableExtension – less mess

Even if like events very much which were in previous version of extensions, I think that they make our code little messy. It was (still is) possible to create as many events to one publisher (for example OnAfterDelete) as you wish. Of course it can be controled but it take more effort for everyone involved in development.

Now we have two options to add events to table. First one – old way (by the way it is very weird that about events I can say old way). And this option is quite hard if you either not use my snippets or you do not remember the structure of event.

And new one which means – Table extension

snippet: ttableext

What is it?

Table extensions give us quite great stuff which we can do:

Add Table Triggers

First of all we can add database triggers and finally we do not need to think about name of the function. Also we do not need to use Rec anymore. As you can see below we can choose all options which had been used before so there is no additional thing here but to be honest it gives as full scope of what we need to do.

Field Triggers

If we want to add field trigger it is also possible with table extension. first we need to declare that we want to change the field (in screen below modify) and then we can choose trigger OnAfterValidate or OnBeforeValidate.

Add fields

Adding fields to standard table also can be done via table extensions. We also can add code directly below the field as it was when we developed without events.

 

Some limitations or not?

One thing which you need to remember developing your solution is that there is possibility to add to table only one extension in your solution. Means that all need to work on the same al file.

This can be also benefit as I said at beginning – we will have less mess in our code. And to be honest I really feel this is good idea to have all in one place: new fields, field events and database events.

 

 

Add a Comment

Your email address will not be published.