Options

Using global variable in page event subscriptions

Cem_KaraerCem_Karaer Member Posts: 281
Hello all,

When creating a publisher function, we can use IncludeSender and GlobalVarAccess for accessing global variables of the publishing object. However, I cannot find any means like this while subscribing to standard page events (OnAfterGetRecordEvent, OnOpenPageEvent, etc.). There are so many customizations for calculating variables for only display purposes on a page. I want to put them out of the page context for better maintainability. What is the best practice for it?
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 2005

Answers

  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    The best practice in my opinion is to keep code strictly related to the UI with the UI, ie on the page.

    There is not much sense in moving code controlling visiblity of specific page elements outside the page as it is very closely logically tied to specific page, and it is very very unlikely that it will be ever used for anything else.


    Note that this is not exactly the same as the code calculating the condition when to show / hide some part of the page.

    For example - if I have a page showing a Customer, and part of the page was visible controled by the domestic / foreing customer condition - I would keep the code checking that condition on a page (albeit in a separate function ie IsCustomerDomestic or something similar).

    If however I've had a part of the page controlled by a more complicated condition. for example: was there any credit memos issued for the customer for more that £100 in last month or so - such code I would likely put in a separate place (a codeunit or a function on a table)

    My 0.01£


    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Options
    Cem_KaraerCem_Karaer Member Posts: 281
    Hello Slawek, thank you for your answer.
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
Sign In or Register to comment.