web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Adding code to a created custom page using extensions

(0) ShareShare
ReportReport
Posted on by 2,582

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

I have the same question (0)
  • Verified answer
    Mohana Yadav Profile Picture
    61,180 Super User 2026 Season 1 on at

    you can do in both ways whichever is feasible to you..

  • Tina Menezes Profile Picture
    2,582 on at

    Ok. Thank you.

  • Verified answer
    Alexander Ermakov Profile Picture
    28,096 on at

    Please refer to Extension Packages Capability Support Matrix:

    msdn.microsoft.com/.../mt574414(v=nav.90).aspx

    An extension package can contain both new and modified objects. In Microsoft Dynamics NAV 2016, codeunitscan be added and included in an extension. You cannot modify any existing C/AL code, including code in codeunits and in triggers on existing objects. If you want to modify existing code, use the new C/AL eventing model. This restriction is only on existing code and objects. However, new pages, tables, and so on, can contain C/AL code as it is considered part of the new object.

  • Community Member Profile Picture
    on at


    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

  • Suggested answer
    Mohana Yadav Profile Picture
    61,180 Super User 2026 Season 1 on at

    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.

  • Suggested answer
    Mohamad Barada Profile Picture
    180 on at

    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.

  • Community Member Profile Picture
    on at

    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?

  • Suggested answer
    Mohamad Barada Profile Picture
    180 on at

    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:

    Event-Subscriber.PNG

    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.

  • Community Member Profile Picture
    on at

    Hi, thank you very much.

    i've created a new codeunit, and in this, new function with publisher that you've find

    0474.event.JPG

    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 ??

  • Verified answer
    Mohana Yadav Profile Picture
    61,180 Super User 2026 Season 1 on at

    you have to raise a request to Microsoft add to a publisher there.

    Microsoft will review and add

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans