AL icon indicating copy to clipboard operation
AL copied to clipboard

"The name does not exist in the current context" for standard tables

Open sgiordy opened this issue 8 years ago • 13 comments

If you try to extend a page that refers to a standard table, you cannot access the record variable. Example:

pageextension 51000 P51000 extends "User Card"
{
  trigger OnAfterGetRecord()
  begin
    message("User Security ID");
  end;
}

During the Publish-NAVApp you get this error:

error AL0118: The name 'User Security ID' does not exist in the current context

sgiordy avatar Feb 08 '18 18:02 sgiordy

This should definitely work. If everything compiles fine in VSCode, this could be a problem with application symbols on the server (e.g. the server compiler has no knowledge of fields in standard tables).

  • What version of AL extension and Nav server do you have?
  • What symbols do you have published on the server: Get-NAVAppInfo -SymbolsOnly
  • Are you using automatic symbols generation in C/SIDE (and EnableSymbolLoadingAtServerStartup setting on the server)?

defr0std avatar Feb 09 '18 09:02 defr0std

We are working with NAV 2018 CU1 in the italian localization.

The AL extension is that provided on NAV DVD: 0.12.15898

The symbols has been already loaded:

Id            : d4a14f4a-0ae8-4501-a527-b3e36c0c3d67
Name          : Test
Version       : 11.0.19846.0
Publisher     : Microsoft
ExtensionType : ModernDev
Id            : 8874ed3a-0643-4247-9ced-7a7002f7135d
Name          : System
Version       : 11.0.12925.0
Publisher     : Microsoft
ExtensionType : ModernDev

Yes we use automatic symbol generation and the server has EnableSymbolLoadingAtServerStartup enabled.

sgiordy avatar Feb 09 '18 17:02 sgiordy

Could you please try to re-generate all symbols in C/SIDE by running: finsql.exe Command=generatesymbolreference, Database="your-db", ServerName=your-server Does the problem still occur after that?

defr0std avatar Feb 12 '18 11:02 defr0std

I have re-generated the symbols many many times :) and... yes, the issue is still present (also with CU2) You can simply reproduce the issue with the code above.

sgiordy avatar Feb 12 '18 18:02 sgiordy

I can't reproduce the problem with your code. Have you tried to Enable Code Analysis for AL to get the exact “problem”. Se how to do that here: https://community.dynamics.com/nav/b/navericwauters/archive/2018/01/22/enable-code-analysis-for-al

HelleChr avatar Feb 13 '18 12:02 HelleChr

@HelleChr the issue is during the Publish-NAVApp not while creating the package. There is no warning by VSCode. I think is a problem with non-WW localizations.

al1 al2

sgiordy avatar Feb 13 '18 17:02 sgiordy

I think I understand what is wrong. The User table is defined the System symbols package. This package must be published to the server in order for the server-compiler to know what a User table (and all User fields) is. Get-NavAppInfo showed that you only have Test symbols published on the server, but not System.

You can read more about symbols here

defr0std avatar Feb 15 '18 11:02 defr0std

@dennisfrostlander no, System symbols are already loaded. See my previous post.

Id            : 8874ed3a-0643-4247-9ced-7a7002f7135d
Name          : System
Version       : 11.0.12925.0
Publisher     : Microsoft
ExtensionType : ModernDev

sgiordy avatar Feb 15 '18 15:02 sgiordy

Of course, disregard my silly comment before :) I somehow read only the first part of the output.

defr0std avatar Feb 15 '18 15:02 defr0std

I cannot reproduce it on the latest NAV 2018 docker image that I created through:

New-NavContainer -accept_eula -containerName "NAV2018" -imageName "microsoft/dynamics-nav" -includeCSide -doNotExportObjectsToText

Your code compiles and publishes without any problems:

pageextension 50105 P51000 extends "User Card"
{
  trigger OnAfterGetRecord()
  begin
    message("User Security ID");
  end;
}

Please contact Support for further assistance.

StanislawStempin avatar Apr 16 '18 11:04 StanislawStempin

Thank you @StanislawStempin I will request for a fix-backport into NAV2018 through Partner Source.

sgiordy avatar Apr 16 '18 18:04 sgiordy

I actually tested it on NAV 2018 CU4 so the issue must already be fixed. Please check that your environment is correctly set up.

StanislawStempin avatar Apr 16 '18 19:04 StanislawStempin

@sgiordy I can confirm that with the Cronus DB (CH) from CU 4 the issue is solved.

BUT: When you upgrade an existing DB, in our case from CU2 to CU4, the problem still persits.

What we detected: This is how the Cronus DB from DVD (CU4) looks like image

This is how our DB looked like image

Symbols for Application are "missing", even after running generatewithsymbols for all objects.

What we did: ***** Note: This is a "hack" - always save your database before you continue. NEVER use in production environement *****

  1. Uninstall Test and System App from your DB (Unpublish-NAVapp -ServerInstance XYZ -Name Test (System)
  2. Restore the Cronus DB from the DVD (Source)
  3. with TSQL, Copy the 3 records (Test, System, Application) from Table [NAV App] and [NAV App Resource] from Cronus DB CU to your destination DB. Take care of the WHERE Clause, do not copy other Apps.

At least, this did the trick for me. I did not face any negative consequences untill now.

bleisibach avatar Apr 20 '18 08:04 bleisibach