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

Using my own database part 2 #397

Closed GreatScott000 closed 7 years ago

GreatScott000 commented 7 years ago

I am trying to take a custom and make it an Extension. I need to use a GB database. I have successfully been able to convert and connect the database to the RTC (see #395 ). The next challenge is to run the HelloWorld extension against it.

I have successfully run the HelloWorld extension against the Demo Database.

Next step, change the "Navision-main" service to use my database. I changed the service and restarted it.

Clearly there are some problems, see below. Questions:

  1. Why is the extension failing to compile?
  2. Why does changing locale cause problems downloading the symbols?

When I run the example I get this the following error. Error Could not publish the package to the server. See Visual Studio Code debug console for more details Close Open launch.json

Debug Window

[2017-07-20 10:46:37.81] Publishing package to http://localhost:7049/navision_main/dev/apps?tenant=default [2017-07-20 10:46:37.92] Error: The request failed with code 422, reason: Extension compilation failed error AL1024: A package with publisher 'Microsoft', name 'System', and a version compatible with '10.0.0.0' could not be loaded. (1,48): error AL0247: The target Page "Customer List" for the extension object is not found

Output Window Microsoft (R) AL Compiler version 0.7.11459 Copyright (C) Microsoft Corporation. All rights reserved

Success: The package is created.

The customer list page is in the database and is compiled. customer list

Event Viewer shows

Server instance: Navision_main Category: Development ClientSessionId: 00000000-0000-0000-0000-000000000000 ClientActivityId: 00000000-0000-0000-0000-000000000000 ServerSessionUniqueId: 57dc93b6-873d-439b-8dea-9d0d58d566e7 ServerActivityId: 73ead87b-cc1c-4e2b-9025-40b0db9450df EventTime: 07/20/2017 09:53:04 Message Failed request -- Method:POST; Url:http://localhost:7049/navision_main/dev/apps?tenant=default; StatusCode:422; ReasonPhrase:Unprocessable Entity; ResponseBody: {"Message":"Extension compilation failed\r\nerror AL1024: A package with publisher 'Microsoft', name 'System', and a version compatible with '10.0.0.0' could not be loaded.\r\n(1,48): error AL0247: The target Page \"Customer List\" for the extension object is not found\r\n"} ProcessId: 8752 Tag: 00000LY ThreadId: 49 CounterInformation:

launch.json unchanged

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "al",
            "request": "publish",
            "name": "Local server",
            "server": "http://localhost",
            "serverInstance": "navision_main",
            "tenant": "default",
            "windowsAuthentication": true,
            "startupObjectId": 22
        }
    ]
}

app.json unchanged

{
  "id": "02ed1bbd-6bc7-4f4b-8844-7dfbb200e252",
  "name": "ALProject1",
  "publisher": "Default publisher",
  "brief": "",
  "description": "",
  "version": "1.0.0.0",
  "compatibilityId": "1.0.0.0",
  "privacyStatement": "",
  "EULA": "",
  "help": "",
  "url": "",
  "logo": "",
  "capabilities": [],
  "dependencies": [],
  "screenshots": [],
  "platform": "10.0.0.0",
  "application": {
    "version": "10.0.0.0",
    "locale": "W1"
  }
}

Noting the locale is set to W1 in app.json I change it to be GB as that is what my database is. Now I get the following when I try and run the extension. The package is not even created.

app.json updated

{
  "id": "02ed1bbd-6bc7-4f4b-8844-7dfbb200e252",
  "name": "ALProject1",
  "publisher": "Default publisher",
  "brief": "",
  "description": "",
  "version": "1.0.0.0",
  "compatibilityId": "1.0.0.0",
  "privacyStatement": "",
  "EULA": "",
  "help": "",
  "url": "",
  "logo": "",
  "capabilities": [],
  "dependencies": [],
  "screenshots": [],
  "platform": "10.0.0.0",
  "application": {
    "version": "10.0.0.0",
    "locale": "GB"
  }
}

Error Could not download symbols. Please see the Visual Studio Code output log for more details. Try again Close

The output folder shows:

[2017-07-20 10:35:53.56] Using reference symbols cache path: c:\Users\evodev1\Documents\AL\ALProject1\packages [2017-07-20 10:35:53.61] Downloading from http://localhost:7049/navision_main/dev/packages?publisher=Microsoft&appName=GB&versionText=10.0.0.0 ... Error (NotFound) [2017-07-20 10:35:53.61] Could not download reference symbols

Event log shows:

Server instance: Navision_main Category: Development ClientSessionId: 00000000-0000-0000-0000-000000000000 ClientActivityId: 00000000-0000-0000-0000-000000000000 ServerSessionUniqueId: 00000000-0000-0000-0000-000000000000 ServerActivityId: 00000000-0000-0000-0000-000000000000 EventTime: 07/20/2017 09:35:53 Message Failed request -- Method:GET; Url:http://localhost:7049/navision_main/dev/packages?publisher=Microsoft&appName=GB&versionText=10.0.0.0; StatusCode:NotFound; ReasonPhrase:Not Found; ResponseBody: ProcessId: 8752 Tag: 00000LY ThreadId: 22 CounterInformation:

defr0std commented 7 years ago

Let me first explain the process.

  1. Compiling locally. When you compile in VSCode, we need to have symbol .navx files locally. The compiler looks inside to find the information about the objects your are extending, etc. The compiler looks into the app.json file and reads the locale (W1, GB, etc) and expects to find the corresponding .navx file locally. Since you don't have a GB navx file, you would have to use W1 in app.json.

    Is there any specific GB customization you need to use in your AL code? For example, do you want to use a field which exists in GB, but not in W1? If not, then W1 symbols should work just fine.

  2. Compiling on the server. When you press F5, the code is compiled on the server and the same story repeats - the server needs to have corresponding .navx files published in the database. Since this is a custom database, these .navx files are missing and the server compilation fails.

    In order to publish .navx symbols to the server, you have to use the standard publishing commandlet with the special -SymbolsOnly flag. I can't try it myself right now, but I can check later today. Let me know if this does not work.

GreatScott000 commented 7 years ago

I feel like I am coming into an advance quantum physics course 2 months after it started and no one can point me to the material I missed. Is there documentation on how to use VS Code to create NAV extensions, that start from scratch and not that you have the environment created by some impenetrable process that already has everything set up?

GreatScott000 commented 7 years ago

The Publish-NAVApp cmdlet has an undocumented (although there is an example for it) parameter PackageType with a value of SymbolsOnly. Is this what you mean?

In order to use it I need a NAVM file, how do I create that? Why is there not one for the HelloWorld example? Where were the symbols created from if this file does not exist?

I am not currently using any specific GB field or object but it is only a matter of time.

However the first error I get (using locale W1)

Error: The request failed with code 422, reason: Extension compilation failed error AL1024: A package with publisher 'Microsoft', name 'System', and a version compatible with '10.0.0.0' could not be loaded.

would seem to indicate that it is the Microsoft_System_10.0.12925.0.navx file that is the culprit. What generated this file? What conditions cause the need for this file?

GreatScott000 commented 7 years ago

Okay so, the app.json file is the basis for the manifest file so I assume that internally a NAVM file is created from that and then the NAVX is generated?

defr0std commented 7 years ago

At this point you should be able to build in VSCode and publish to the server with F5.

The reason why you get this error:

The request failed with code 422, reason: Extension compilation failed error AL1024: A package with publisher 'Microsoft', name 'System', and a version compatible with '10.0.0.0' could not be loaded.

Is because this is the first missing-dependency-error that happens on the server and publishing does not proceed further. We will look into improving the error output in this case.

In general you're right - for now we only provide the server and database with US symbols loaded. The other configurations will also follow, as well as documentation on how to create and use your own symbols.

ghost commented 7 years ago

Thank you for this last sentence. That for me is the golden nugget! "The other configurations will also follow, as well as documentation on how to create and use your own symbols."

The way I read this is: As a NAV Reseller you can add as many events to the base products as you want with handled pattern and all. Then create your own packages.

This will be great for the adoption of VS Code in the traditional NAV ecosystem.

GreatScott000 commented 7 years ago

I am trying to understand this. As of the July Preview release, I can only build an extension against a W1 database?
I am not, currently, able to produce an extension that references a region specific object or a region modified object?

defr0std commented 7 years ago

In July Preview, not as of. We are working on switching back to region specific symbols.

GreatScott000 commented 7 years ago

And up to July you could only use the US database? My question is how can I use my GB database? When or how will this be possible?

defr0std commented 7 years ago

Providing images with GB and CA setup in the next thing on the radar, but I can't provide the exact date right now. We will keep you posted.

GreatScott000 commented 7 years ago

Thank you for the information and your patience. I am just trying to get my arms around this new world. I find it exciting and want to get started.

nicojmb commented 6 years ago

Hi, I've downloades the latest NAV version 11.0.9394.0 and latest vscdoe AL plugin.

But Page "Customer List" not found, my NAV version is es-ES

{ "version": "0.2.0", "configurations": [ { "type": "al", "request": "launch", "name": "Desarrollo", "server": "http://desarrollo", "serverInstance": "Cronus_2018_19394", "authentication": "Windows", "startupObjectId": 22 } ] }

image

1181

defr0std commented 6 years ago

I suggest that you open a new issue, we don't usually look at old closed issues.