I want to write a common code in OnOpen trigger of all pages in NAV 2015. As the number of pages are too many, I am looking for a single place to write this code which will work for all pages ( like some functions in codeunit 1). Is is it possible? If yes, then please suggest how.
I’m sorry but no such functionality exists in Dynamics NAV.
The next best thing could be to create a common codeunit, you then call from your triggers.
But I’m also curious about what you’re really trying to do?
Thanks for your response.
Actually, I am developing a functionality to track the open pages; when a page is opened, closed and for how long the page is opened.
Actually I used the superb tool Objected Manager Advanced from Idyn to insert an OnOpen trigger in all pages and forms.
OMA has the ability to compile an object, export it to text file, import it to a temporary table, change the code (sort variables, delete unused variables, – and here I added the code to insert an OnOpen trigger --), export the code to text file, import the object from text file and compile the object.
This mass substitution can also be used to replace find(’+’) by findlast or else.
At the OnOpen trigger there is not transaction started, so I saved the log information into a temporary table and saved it on logout in codeunit 1.
Ignore ‘transaction started’. I preferred to use a single instance codeunit like saving the report usage.
Is this tool OMA available for free use or need to purchase?
One question is left. What can be done on the OnOpen trigger?
I added the same code line ReportUsageMgt.AddObject(2,ObjectID(false)) to all forms. (Replace the 2 for other object types). Report Usage Mgt. is a single instance codeunit, where the log info is stored into a temporary table (i used table Line Number Buffer). In codeunit 1, LoginEnd, I used ChangeLogMgt.LogInsertion to create a Change Log Entry for the table Object. This implementation fits smoothly to all systems.
If security matters - you can see now all activities of the users in the change log entries. And more, after some time, you can create a role giving read permissions on forms. This adds more security to user right management based only on table permissions.
@Radheshyam OMA is not free, but a tool for partners to do a lot of the help you manage NAV development better than today. You can find more information here:
@Holger You should avoid code that does any updates to the system on the page triggers. If you do have a need for doing some coding, then do this code in codeunits that you call from the page.