Skip to content

How To: Work with Multiple AL Projects in One Workspace Using Visual Studio Code in Microsoft Dynamics Business Central On Premises How to work with multiple AL projects in one workspace using Visual Studio Code

If you’re new to Microsoft Dynamics Business Central on premises, you need to know how to easily customize it. In this blog, you’ll learn how you can work with multiple AL projects in one Visual Studio Code editor in Microsoft Dynamics Business Central on premises.

  1. Create a new AL extension using view -> Command palette – AL:Go or using the keyboard shortcut -> Ctrl+Shift+P -> AL Go
    Figure 1 – Creating a new extension in Dynamics Business Central on premises
    Figure 1 – Creating a new extension in Dynamics Business Central on premises
  2. Create the first extension with the path. In the example in Figure 2, the extension name is AL Workspace
    Figure 2 – Creating a new extension with path and extension name in Dynamics Business Central on premises
    Figure 2 – Creating a new extension with path and extension name in Dynamics Business Central on premises
    Next, some basic configuration settings in Launch. json file need to be done.
    Figure 3 – Configuration settings for Launch. json file in Dynamics Business Central on premises
    Figure 3 – Configuration settings for Launch. json file in Dynamics Business Central on premises
    Note: In this app. json file, there is no need to change anything/ You can change the publisher name or just leave it as is.
    Figure 4 – Configuration settings for app. json file in Dynamics Business Central on premises
    Figure 4 – Configuration settings for app. json file in Dynamics Business Central on premises
    In Figure 5, the HelloWorld.ai file shows an error because it does know what “customer list” means, so you need to download the symbols.
    Figure 5 – HelloWorld.al file in Dynamics Business Central on premises
    Figure 5 – HelloWorld.al file in Dynamics Business Central on premises
  3. To download symbols, use view ->command palette ->AL: Download symbols or use the keyboard shortcut Ctrl+Shift+P ->AL: Download symbols
    Figure 6 – Downloading Symbols for the HelloWorld.al file in Dynamics Business Central on premises
    Figure 6 – Downloading Symbols for the HelloWorld.al file in Dynamics Business Central on premises
    In Figure 7, you can see that there are no errors in “customer list”, and you get the notification that all reference symbols have been downloaded. On the left side of the screen, you have an .alpackages folder with two app files.
    Figure 7 – Symbols are downloaded and .al packages folder in Dynamics Business Central on premises
    Figure 7 – Symbols are downloaded and .alpackages folder in Dynamics Business Central on premises
  4. Create a second extension using the same steps, but with the path and name AL Workspace 2, as shown in Figure 8.
    Figure 8 – Creating a new extension with file name and extension name in Dynamics Business Central on premises
    Figure 8 – Creating a new extension with file name and extension name in Dynamics Business Central on premises
    Once the configuration settings in launch. json and app. json files (the same as AL Workspace1) are complete, you get the HelloWorld.Al file with errors in “customer list”.
    Figure 9 – HelloWorld.al file in AL workspace2 in Dynamics Business Central on premises
    Figure 9 – HelloWorld.al file in AL workspace2 in Dynamics Business Central on premises
  5. To add the first project, the AL Workspace1 needs to be in the same editor (AL Workspace2). Do this by adding the folder to workspace. The workspace is just a combination of multiple AL projects in one file.
    Figure 10 – Adding the AL Workspace1 folder to AL workspace2 in Dynamics Business Central on premises
    Figure 10 – Adding the AL Workspace1 folder to AL workspace2 in Dynamics Business Central on premises
  6. Select AL Workspace1, and you will see that you have AL workspace2 and AL workspace 1, as shown in Figure 11.
    Figure 11 – AL workspace1 added to AL workspace2 in Dynamics Business Central on premises
    Figure 11 – AL workspace1 added to AL workspace2 in Dynamics Business Central on premises
    The symbols are still missing because in AL Workspace2, “customer list” is not defined. But in AL Workspace1, it knows what “customer list” means because the symbols in the AL packages folder have been downloaded.
    Figure 12 – AL workspace1 added in AL workspace2 with symbols still missing in Dynamics Business Central on premises
    Figure 12 – AL workspace1 added in AL workspace2 with symbols still missing in Dynamics Business Central on premises
  7. Save the workspace.
    Figure 13 – Saving the workspace to the desktop in Dynamics Business Central on premises
    Figure 13 – Saving the workspace to the desktop in Dynamics Business Central on premises
  8. In Figure 14, you can see it, entitled workspace. Save this workspace to the desktop: Save file, save workspace as. In this example, it is saved as My Ext.
    Figure14 –  Workspace is saved on the desktop with workspace name My Ext in Dynamics Business Central on premises
    Figure14 –  Workspace is saved on the desktop with workspace name My Ext in Dynamics Business Central on premises
    If you go to Windows file Explorer, you can see that in the “Desktop” folder, there is a file with extension code “workspace”.
    Figure 15 – Workspace is saved with extension “workspace” in Dynamics Business Central on premises
    Figure 15 – Workspace is saved with extension “workspace” in Dynamics Business Central on premises
  9. You now have a workspace with two projects, AL workspace1 and AL workspace 2. To share the symbols in AL workspace1 with AL workspace2. create a folder by clicking Add Folder to Workspace and Ref.symbol.
    Figure 16 – Adding a new folder in the workspace in Dynamics Business Central on premises
    Figure 16 – Adding a new folder in the workspace in Dynamics Business Central on premises
    Figure 17 – Trying to add a new folder to the workspace in Dynamics Business Central on premises
    Figure 17 – Trying to add a new folder to the workspace in Dynamics Business Central on premises
    Figure 18 – New folder is added in the workspace in Dynamics Business Central on premises
    Figure 18 – New folder is added in the workspace in Dynamics Business Central on premises
  10. Add this folder to the workspace. You now have three folders: AL workspace1, AL workspace2, and the folder Ref.Symbol.
    Figure 19 – Total of three folders in the workspace in Dynamics Business Central on premises
    Figure 19 – Total of three folders in the workspace in Dynamics Business Central on premises
  11. Copy the .alpackages folder in AL Workspace1.
    Figure 20 – Copying the .alpackages folder in AL workspace1 in Dynamics Business Central on premises
    Figure 20 – Copying the .alpackages folder in AL workspace1 in Dynamics Business Central on premises
  12. After copying, the next step is to paste it in Ref.Symbol folder and then remove it from AL workspace1, as shown in Figure 22. When you restart Visual Studio Code, you can see that in this case, your Visual Studio Code is completely launched, your AL Workspace2 doesn't know anything about “customer list”, but the same is true for your AL workspace1. It doesn't recognize “customer list” anymore. This is because now the package, AL package, is in the folder Ref.symbol, so it doesn't know where to find them.
  13. Use this shortcut to address this. Go to the settings. There are three types of settings: the default settings, the user settings, the workspace settings, and the folder settings. If you go to the default settings and scroll down, you can see that there's a setting for pretty much every file extension, including the AL language extension. In there, there's a setting called AL package cache path, which has a reference to the AL packages folder.  This is by default.  Go to the root, then to the folder Ref.symbol, and indicate your package cache is in the folder AL packages, as shown in Figure 21.
    Figure 21 – Selecting .alpackages in Ref.Symbol folder in Dynamics Business Central on premises
    Figure 21 – Selecting .alpackages in Ref.Symbol folder in Dynamics Business Central on premises
    Figure 22 – Setting information for adding the .alpackages path in Dynamics Business Central on premises
    Figure 22 – Setting information for adding the .alpackages path in Dynamics Business Central on premises
  14. Save, close, and open Visual Studio Code again. Now, open the Workspace (My Ext), as shown in Figure 23.
    Figure 23 – Opening the workspace in Dynamics Business Central on premises
    Figure 23 – Opening the workspace in Dynamics Business Central on premises
  15. Wait a couple of seconds, and now your Visual Studio Code knows what “customer list” is in AL workspace2 and knows what “customer list” is in AL workspace1. So, now, your packages are shared across two projects.
    Figure 24 – Result for multiple AL projects in one workspace in Dynamics Business Central on premises
    Figure 24 – Result for multiple AL projects in one workspace in Dynamics Business Central on premises

 

If you have any questions about Dynamics NAV or Business Central for any topic and any version, contact ArcherPoint.

Read more "How To" blogs from ArcherPoint for practical advice on using Microsoft Dynamics Business Central or NAV.

If you are interested in NAV/Business Central development, check out our collection of Development Blogs.

Blog Tags: 
Read ArcherPoint's Blog Follow us on Twitter Follow us on Facebook Follow us on LinkedIn Link to our RSS feed Watch us on YouTube
Get Help Now