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
719 stars 242 forks source link

Switching page view unexpectedly initializes global page variables #7717

Closed jhoek closed 2 months ago

jhoek commented 2 months ago

Please include the following with each issue:

1. Describe the bug When users switch between (built-in or user-defined) page views, the page's global variables are reinitialised, thus losing the page "state".

2. To Reproduce Steps to reproduce the behavior:

  1. Run the following page, populate the "Test" column for a few of records.
  2. Press F5 to verify that the page state is maintained.
  3. Create a user-defined view, e.g. one that filters on the Name field = '*a*'.
  4. In a record that satisfies the view's criteria, type a value into the "Test" column.
  5. Switch back to the "All" view and note that the value entered in the previous step is lost.
page 50100 Test
{
    PageType = List;
    ApplicationArea = All;
    UsageCategory = Lists;
    SourceTable = Customer;

    layout
    {
        area(Content)
        {
            repeater(Control1)
            {
                field("No."; Rec."No.") { }
                field(Name; Rec.Name) { }
                field(Test; MyInteger)
                {
                    BlankZero = true;

                    trigger OnValidate()
                    begin
                        MyGlobal.Set(Rec."No.", MyInteger);
                    end;
                }
            }
        }
    }

    trigger OnAfterGetRecord()
    begin
        MyInteger := 0;

        if not MyGlobal.Get(Rec."No.", MyInteger) then;
    end;

    var
        MyInteger: Integer;
        MyGlobal: Dictionary of [code[20], Integer];
}

3. Expected behavior Switching views, like refreshing the page with F5, should retain its state (i.e. it's global variables).

4. Actual behavior State is lost.

5. Versions:

Final Checklist

Please remember to do the following:

BazookaMusic commented 2 months ago

This is a runtime issue and potentially a breaking change, so not fit for this repository.

Let's get the issue to a team who will fix and backport it, as this repository is only for issues related to the AL compiler in latest developer preview environment for Dynamics 365 Business Central. We suggest that you open a support case or file a bug in Collaborate, to ensure that all Business Central users benefit from your catch as soon as possible.

To open a support case, you can:

Open a support request to CSS through the PartnerSource portal Contact your Service Account Manager (SAM) in your local subsidiary to understand what is included in your contract as of support incident and PAH (Partner Advisory Hours). Your SAM might also direct you "step by step" how to open a support request or how to get credentials, if this is the first time for you or your company If you file the bug in Collaborate, remember to include steps to reproduce the issue, and the Business Central build number and country version you're using.