How to get access to C/AL code in NAV Developer Preview September Update

12 Sep

The NAV Developer Preview is meant to create extensions and not to do any customizations in the base application. However, you may want to have at least access to the base code to see what has been changed, which functions are external, etc.

If you created an Azure VM right away after the announcement of the September Update, you might be missing C/SIDE on the desktop. If that is the case, then you should recycle your VM and create a new one. The latest image version contains a C/SIDE shortcut on the desktop. Or you can skip to below how to get access via PowerShell.

C/SIDE

On the desktop you will find a shortcut FinSql.

It will automatically try to open the correct database, but you have to type in credentials.

These are the credentials you muse use:

  • Username: SA
  • Password: same password as NAV admin user

The server name is: NAVSERVER\SQLEXPRESS

With this, you should be able to connect to the database, change the license and export objects.

PowerShell

To access with PowerShell follow these steps. These steps also demonstrate how you can exchange files between the container and the host system.

All steps below should be executed on the Azure VM

Step 1: Copy a development license to the folder C:\myfolder

LicenseInMyfolder

This folder is shared with the docker container. Inside the docker container it is known as C:\run\my.

Step 2: Open the NAV Container PowerShell prompt from the desktop

 

Step 3: Import the development license to the NAV server

Run this command:

Import-NAVServerLicense -ServerInstance NAV -LicenseFile 'C:\run\my\NAV2017 USA.flf'

Again, the folder C:\myfolder on the Azure VM becomes C:\run\my inside the container.

ImportNAVServerLicense

Step 4: Get NAV Server settings

Run this command:

Get-NAVServerConfiguration -ServerInstance NAV

GetNAVServerConfiguration

Now you know the database details. You need them for the next step.

Step 5: Export the NAV objects to text

Run this command, and use the settings you found in the previous step:

Export-NAVApplicationObject -DatabaseServer localhost\sqlexpress `
                            -DatabaseName FinancialsUS `
                            -Path C:\run\my\NAVTenerifeObjects.txt

ExportNAVObjects

And you will get the complete export in C:\myfolder on the Azure VM!

ExportNAVObjectsOutput

Step 6: Explore it with a source code analyzer

Load the object file into a C/AL code analyzer of your choice.

19 thoughts on “How to get access to C/AL code in NAV Developer Preview September Update

  1. Pingback: How to get access to C/AL code in NAV Developer Preview September Update - Kauffmann @ Dynamics NAV - Dynamics NAV Users - DUG

  2. As alternative way: I copied sql database files (Demo Database NAV(11-0)_data.mdf and ldf) from container folder:
    “C:\ProgramData\docker\windowsfilter\0ad35e5c83b9dbc9206f8602cddc9de6166ec891fde3833089ccf91d05675bbf\Files\databases” to my local pc.
    And NAV server and Client files from similar container folder: “C:\ProgramData\docker\windowsfilter\0ad35e5c83b9dbc9206f8602cddc9de6166ec891fde3833089ccf91d05675bbf\Files\Program Files (x86)”.
    I’ve attached db to my local SQL and connected with copied NAV… Works 🙂

  3. Hi

    Is it possible to open the NAV Container PowerShell prompt when running docker on my local machine, rather than on an Azure VM?

    Cheers

    Chris

  4. Hello,
    I am trying to implement an api call through NAV 2015, I have tested the code in business central and it is working fine( thanks to your help too). The code is using

    content: HttpContent;
    client: HttpClient;
    contentHeaders: HttpHeaders;
    ResponseMessage: HttpResponseMessage;

    I have declare this variable under View-> C/AL Globals -> Variables

    Name=content Data Type->DotNet Subtype -> System.Net.Http.HttpContent.’System.Net.Http, Version=4.0.0.0, Culture=neutral,
    Name=client Data Type->DotNet Subtype -> System.Net.Http.HttpClient.’System.Net.Http, Version=4.0.0.0, Culture=neutral,

    The code as below onRun()
    content.WriteFrom(‘{“query”: “query {ping}”‘); // Data to be sent on the body of the request
    content.GetHeaders(contentHeaders); // type of object : HttpHeaders
    contentHeaders.Remove(‘Content-Type’); // content type default need to be removed

    The error I am getting is –> You have specified an unknown variable WriteForm

    • WriteFrom expects a variable, not a literal. Is a missing feature if you ask me.
      Can be solved by using a textconst or a text variable with the value you want to write.

  5. Thanks for your answer
    I tried using a text variable but the same problem. Never experienced this in other programming languages

    bodyrequest:='{“query”: “query {ping}”‘;
    content.WriteFrom(bodyrequest); // Data to be sent on the body of the request

    Do you have any idea, what this might be?

  6. Yes you are correct, I can’t use most of the procedures of HttpContent in C/AL Nav 2015 so I have to reproduce all the code used in Business Central to make it compatible for NAV 2015

    • Sorry to bother you again, but I have been struggling to find a solution to implement a POST API call in Nav 2015 I have made it work in Business central but most of the procedures aren’t available in NAV. I have tried to use codeunit 1290 Web Service Request Mgt. but the 2015 version have limited procedures, also have tried to create the codeunit 1297of the NAv 2016 version but without success at the moment
      The code I am trying to implement is pretty simple but can;t find the right way to do it on 2015 , and since it is a old version your blog is one of the few sources I have found
      The code I am trying to implement in NAV 2015 looks like the problem is with using the HttpContent procedures and the HttpClient.Post procedure aren’t working

      var
      client: HttpClient;
      content: HttpContent;
      contentHeaders: HttpHeaders;
      ResponseMessage: HttpResponseMessage;
      response: Text;
      begin
      content.WriteFrom(bodyrequest); // Data to be sent on the body of the request
      content.GetHeaders(contentHeaders); // type of object : HttpHeaders
      contentHeaders.Remove(‘Content-Type’); // contet type deafaul need to be removed
      contentHeaders.Add(‘Content-Type’, ‘application/json’); // Add content type
      client.DefaultRequestHeaders.Add(‘Authorization’, ‘Bearer xxxxxx’); //Authorazitation

      //Send the post Request t
      if not client.Post(‘https://payments.sandbox.braintree-api.com/graphql’, content, ResponseMessage) then
      Error(‘The call to the web service failed.’);
      //Check if the Request has suceed
      if not ResponseMessage.IsSuccessStatusCode then
      error(‘The web service returned an error message:\\’ +
      ‘Status code: %1\’ +
      ‘Description: %2’,
      ResponseMessage.HttpStatusCode,
      ResponseMessage.ReasonPhrase);

      ResponseMessage.Content.ReadAs(response);

      • Not sure what your question is. But in general, I would love to help if you are struggling with getting this to work in Business Central and AL code. But NAV2015 is a long time ago, I don’t even have a version installed. Sorry, I’m afraid I can’t help you further with this one.

  7. Thank for your help, i am thinking about creating a .DLL in C# and upload it in NAV and use the .dll to do the post API call
    Is this something that can be done? cause I don’t have a lot of experience with NAV and C/AL ?
    Thanks

Leave a Reply to Chris Collins Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.