AL icon indicating copy to clipboard operation
AL copied to clipboard

AA0248 in Pageextensions not working as expected

Open stephanweidmann opened this issue 1 year ago • 4 comments

1. Describe the bug AA0248 is shown hidden with 3 dots for a variable, but if you follow the instructions and add the this, AL0847 occurres (Page MainPage does not contain a definition for variable) 2. To Reproduce

  1. Create a page extension with a variable of type boolean, and add a field with enabled = Variable. Image
pageextension 74791 "KVSDMSADVDemo" extends "Company Information"
{
    layout
    {
        addfirst(General)
        {
            field(KVSDMSADVPREBaseCalendarCode; Rec."Base Calendar Code")
            {
                ApplicationArea = All;
                Visible = Variable;
                Enabled = this.Variable;
            }
        }
    }

    var
        Variable: Boolean;

    trigger OnOpenPage()
    begin
        Variable := false
    end;
}

3. Expected behavior No (hidden) warning, or this for pageextension variable

4. Actual behavior Wrong warning, or unsupported this in pageextension

5. Versions:

  • AL Language: 15.0.116424
  • Visual Studio Code:
  • Version: 1.94.1 (system setup) Commit: e10f2369d0d9614a452462f2e01cdc4aa9486296 Datum: 2024-10-05T05:44:32.189Z Electron: 30.5.1 ElectronBuildId: 10262041 Chromium: 124.0.6367.243 Node.js: 20.16.0 V8: 12.4.254.20-electron.0 Betriebssystem: Windows_NT x64 10.0.22631
  • Business Central: 25.0
  • List of Visual Studio Code extensions that you have installed:
  • Operating System:
    • [ x ] Windows
    • [ ] Linux
    • [ ] MacOS

Final Checklist

Please remember to do the following:

  • [X] Search the issue repository to ensure you are reporting a new issue

  • [X] Reproduce the issue after disabling all extensions except the AL Language extension

  • [ x] Simplify your code around the issue to better isolate the problem

Internal work item: AB#562248

stephanweidmann avatar Oct 09 '24 12:10 stephanweidmann

The same problem happens in tableextension in combination with local procedures/global variables on the tableextension level.

TKapitan avatar Oct 27 '24 03:10 TKapitan

To elaborate on this issue, it arises because within the context of Pages and Tables (including PageExtensions and TableExtensions), this is equivalent to CurrPage and Rec respectively, from the scope of the original object.

There is no compile-time error if a local procedure is defined on a tableextension, this allows the publication of breaking code. If a local procedure is defined on a tableextension and then is referenced using the this keyword (as seen below) then upon accessing the table via the Web Client the generic "Something went wrong" error occurs, ending the current operation.


As demonstrated on a page: Image

As demonstrated on a table: Image The call to this.TableExtFunc(); in this image causes a catastrophic error when the table is accessed from the Web Client, despite there being no compile-time error, as there should be (equivalent to the compile-time error AL0161 - 'TableExtFunc()' is inaccessible due to its protection level) as seen on the call to Rec.TableExtFunc(); in this image on the following line.

AidanH91 avatar Jan 09 '25 11:01 AidanH91

doesn't seem to be an important error - no movement for 3 months :/

stephanweidmann avatar Jan 09 '25 12:01 stephanweidmann

Hopefully raising the point that there can be code with no compile-time warnings can create a catastrophic error at table access in the UI might encourage some progress, especially when looking at this.MyExtensionFunction() would be unlikely to raise any eyebrows, at least other catastrophic errors are usually obvious.

AidanH91 avatar Jan 09 '25 12:01 AidanH91