How to do it...

  1. In Visual Studio Code, select File | Open Workspace. Browse to the folder extracted from the ZIP file you downloaded and open the ch3-dependencies.code-workspace file.

A Visual Studio Code workspace can contain multiple projects. In our case, the workspace contains two different AL projects:

  • Parent
  • Child
  1. We need to connect these two projects to our development sandbox.

If you've been working along with this book, you can copy the launch.json file from any of your completed recipe projects and place it in the .vscode folders for each project (there's a folder for both the Child and Parent projects, so make sure you copy the file to both).

If you don't already have a launch.json file from a previous recipe in this book, then you'll need to go back to Chapter 1Let's Get the Basics Out of the Way, and set up a development sandbox. Once you have done that, you can configure a new launch.json file to connect to the sandbox environment.

  1. We now need to download the symbols for these new projects. Because the projects are separate, we have to download the symbols for each project separately.

When working in a workspace, the context in which Visual Studio Code operates is based on which project you have selected:

  1. In Explorer, click on the Parent Page.al file within the Parent folder and press Ctrl + Shift + P to open Command Palette.
  2. Type in or select AL: Download Symbols.
  3. Once the symbols have been downloaded for the Parent project, click on the Child Table.al file under the Child folder in Explorer.
  4.  Press Ctrl + Shift + P to open the Command Palette and type in or select AL: Download Symbols.
  • We've now downloaded the symbol files for both of our projects!
  1. Let's compile our projects.

In Explorer, select the Child Table.al file and press Ctrl + Shift + B to build the project. In the Output window, you should see a message like this:

Success: The package is created.

In Explorer, select the Parent Page.al file and press Ctrl + Shift + B to build the project. You will notice an error like this:

error AL0185: Table 'Child Table' is missing
  1. If you look at the contents of the Parent Page.al file, you will see a reference to Child Table, but that reference is highlighted with a compiler error.

This is because the Parent project does not know about the existence of the Child project, so any references to it cannot be resolved. In order to tell the Parent project about the Child one, we must create a dependency from the Parent to the Child.

In Explorer, select the app.json file under the Parent folder and update the dependencies property as follows:

"dependencies": [
{
"appId": "c5c7fc1e-a0c4-4e16-b4eb-f1b4db2b34c9",
"name": "AL Child Project",
"publisher": "Default publisher",
"version": "1.0.0.0"
}
],
The values that you enter in the dependencies property are found in the app.json file of the app you are adding the dependency for, and can also be found on the Extension Management page in Business Central.
  1. Now that we have told the Parent project about the Child project, we need to download the symbols for the Child project into the Parent project. We need to do this so that we can reference the entities and functions within the Child project.

We need to first publish the Child project to the development sandbox:

  1. Select the Child Table.al file and press F5 to build and publish the Child project. You can just close your browser when it launches.
  2. After the Child project has been published, select the Parent Page.al file and press Ctrl + Shift + P to open the Command Palette.
  3. Type in or select AL: Download Symbols.
If you've published earlier projects from this book to your development sandbox, you'll need to uninstall and unpublish those before you can publish either of these new projects.

Once the symbols have been downloaded to the Parent project, you should notice that you have a symbols file for the Child application that you previously published, similar to this:

  1. Now, let's build the Parent project again.

Select Parent Page.al and press F5 to build and publish the project to your sandbox. This time, it should work and your browser should launch successfully!

The reference to the Child table in Parent Page.al can now be resolved because the Parent project now knows about, and has the symbols for, the Child project.

  1. If you plan on continuing with the recipes in this book, then you will need to uninstall and unpublish both the Child and Parent applications from your development sandbox. You can do that from the Extension Management page.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset