Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA0248 in Pageextensions not working as expected #7867

Open
2 of 4 tasks
stephanweidmann opened this issue Oct 9, 2024 · 4 comments
Open
2 of 4 tasks

AA0248 in Pageextensions not working as expected #7867

stephanweidmann opened this issue Oct 9, 2024 · 4 comments

Comments

@stephanweidmann
Copy link

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:

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

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

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

@TKapitan
Copy link

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

@AidanH91
Copy link

AidanH91 commented Jan 9, 2025

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.

@stephanweidmann
Copy link
Author

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

@AidanH91
Copy link

AidanH91 commented Jan 9, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants