Using global variable in page event subscriptions
Cem_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?
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
Dynamics NAV Developer since 2005
0
Answers
-
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-030 -
Hello Slawek, thank you for your answer.Cem Karaer @ Pargesoft
Dynamics NAV Developer since 20050
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
