microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
747 stars 245 forks source link

Access to Global Temporary variable in page from Page extension #2422

Closed andreilungu closed 6 years ago

andreilungu commented 6 years ago

Version 13.0.22070.0

PAGE 161 "Purchase Statistics"

I am trying to convert custom modification made to this page to a Page Extension.

At the end trigger OnAfterGetRecord we have added a function that does some calculations and copies some values based on the values from global variable "TempVATAmountLine"

The issue is that in the Page Extension we don't have access to this global temporary variable. issue access global var

We have this situation multiple times, not only at this example and sometimes we filled another temporary in the page extension but it is bad practice (duplicating code, executing similar code multiple times), so we want to ask you if there is a better workaround for this ?

Our idea is if you can add an Event publisher in page 161 at the end of OnAfterGetRecord trigger that will contain a by reference parameter of the global variable "TempVATAmountLine". In this way if we subscribe to that event we could have access from the page extension to that global variable that contains values calculated in the page.

Thanks, Andrei Lungu

andreilungu commented 6 years ago

Hello,

I tested with the event added in the new build, but now I think that this solves the issue only partially:

We need the "TempVATAmountLine2" in the page extension because we use it later on to populate a custom added subform.

Please see how it was in 2017 version: customform populate and use tempvatline2

How do you recommend to implement this (preferably without Single Instance Codeunit) ? subscriber codeunit

Event Subscribers cannot be created in a page: event subscribers cannot be created in a page

bogdan81GitHub commented 6 years ago

The same issue happens also for page 401 Purch. Credit Memo Statistics. The scenario is the same with global variable "TempVATAmountLine".