Hi all,
I want to do a customization using extensions. For this, I have created a custom page. I want to add code in this custom page. So do I need to create a codeunit for the code of this custom page since I'm doing it using extensions or can I add the code in the custom page itself ?
*This post is locked for comments
Hi all,
thank for your support. Finally i've created a new codeunit with some function subscribed to events near the custom code I wanted to include in standard objects.
Extensions do not allow any type of code, not even the recall of custom published events; neither the documentation in the objects can be inserted, nor the code in the triggers: nothing of anything.
But now I have a problem, I should add an option type in a standard option field of standard table .... and not even this can be done !! what is the right way in this case? I did not find documentation about it.
thanks so much
Hi,
In this case if you want to add the code within the event function and call this function, you will need to do minor changes to the standard code as inserting code within standard functions using extensions is still not supported. If you want a particular event function you have to raise request to Microsoft.
Before Microsoft raise publisher there you can do the following :
In place of your yellow script you have to call the published and send the variable needed to be changed as VAR .
when you create a subscriber linked to the publisher that you have call it in place of your yellow script the code of your subscriber will be called within the PostGLAcc function. Yes you could keep your script and run it as the old way but the new approach of subscriber will help you when you create extensions to have all your scripts in one place and minor script (only 1 line in this case) inside the regular objects of NAV. It will be also much easier when you upgrade cause you can export your codeunits easily.
you have to raise a request to Microsoft add to a publisher there.
Microsoft will review and add
Hi, thank you very much.
i've created a new codeunit, and in this, new function with publisher that you've find
now i've this code from NAV 2013 :
this code, will be enter in event?
and what i call it, if don't write any code in standar object with extension ??
For Cudeunit 12 you have already 4 publisher one of them is OnBeforePostGenJnlLine(VAR GenJournalLine : Record "Gen. Journal Line") if you want to run your script before postgenjnlline you can use this publisher and create new event subscriber linked to this publisher:
If this event is not suitable for you have to create new function of type publisher and call it in the place within CodeUnit 12 than you have to create new codeunit and new function of type subscriber and link it to the new publisher created and inside the subscriber function you put your script.
I don't know if this will help otherwise please share with me where do you want to add your script and what is the script to be added in order to be able to provide the right example.
Thank you for your reply.
But i've a doubt: when to create the extension, and it involves entering the code in codeunit 12, in the PostGLAcc function, if I can not enter the code, how can I call the event? can you make an example?
If you are working on Microsoft Dynamics NAV 2017, It's better to use the subscriber concept. so you create a new codeunit and you create a new function with type event and subtype subscriber and you select the event required from the available publisher.
Let me know if you need any support to create a subscriber function.
it wont work.
we should not modify code in standard codeunits at all.
if you need then you have to use publishers provided by Microsoft.
hello, if I do not modify the existing code in a standard codeunit, but add another code, the extension works? Or is it not possible to add code to the codeunit? In this case, if I wanted to enter the code as you proceed? thank you
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,836
Most Valuable Professional
nmaenpaa
101,156