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
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.
Step 4: Get NAV Server settings
Run this command:
Get-NAVServerConfiguration -ServerInstance NAV
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
And you will get the complete export in C:\myfolder on the Azure VM!
Step 6: Explore it with a source code analyzer
Load the object file into a C/AL code analyzer of your choice.
Pingback: How to get access to C/AL code in NAV Developer Preview September Update - Kauffmann @ Dynamics NAV - Dynamics NAV Users - DUG
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 🙂
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
Sure, just install the PowerShell module navcontainerhelper and use the command Enter-NavContainer. See https://blogs.msdn.microsoft.com/freddyk/2017/11/03/multiple-ways-to-run-a-nav-on-docker-image/ for more info.
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.
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?
It was a shot in the dark… need to look deeper, can do that later this weekend.
Thank for your help, I will look it into it this weekend too and if I find a solution will post it here
I tried to a simple
textvariable := textvariable.ToUpper();
and I got the below error
The variable is not a record variable.field is invalid
Hello, did you have the chance to take a look I have been struggling with the problem for a while and haven’t found any solutions
Thanks in advance
Yes, I have an answer for you.
Don’t use the HttpContent type directly. Instead, use the .Net StringContent type (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.stringcontent?redirectedfrom=MSDN&view=netframework-4.8)
Use the constructor to set the data. The StringContent inherits from the HttpContent and can be passed to a function that expects parameter of type HttpContent.
For an example see: https://www.kauffmann.nl/2016/01/28/web-services-example-part-4-send-sms-text-message/
Thank you for your response, i tried but still the same problem .
I think is something else cause even when I try a simple procedure like
textvariable := textvariable.ToUpper();
and I got the below error
The variable is not a record variable.field is invalid
That is not supported in C/AL on text variables. Use UPPERCASE instead.
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.
Thank you, you were right using stringContent instead of HttpContent fixed the problem
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