Sunday, December 23, 2018

How to Call an external API from NAV C/AL code




Hello All,

Greetings!

Hope you all are well.

This post will cover how to consume external SOAP API and for this, we would use DotNet variables, which would have some request parameter and response with base 64 code.
In SOAP API we must pass the same structure as per the API method would have. Some of you would be aware that could have multiple methods in a one API.
Therefore, Below I have used DotNet variables







By using these variables, I have written a Codeunit which create xml request and xml response, and then we pass as a parameter to CallWebAPIRequest method. Further, we get response and read with dotnet variables then convert it to base 64 code to .pdf file.   














Here in below screen I have created xml request by using XML Dom Codeunit, you can also use XMLPORT for this.











In addition, here we create a connection with external API and get response; I have just created this Codeunit for demo purpose so in CallWSTop10 method you can do error handling if connection fails due to unexpected issue.
If status code is 200 then out connection is successful one more thing I have used here networkcredential method to pass user and password otherwise, system will through unauthorized error while making connection. User and password we can pass in xml request depends on API request.










By calling this, we get response






In next post, we will cover how to consume Rest Web API.
Thanks.

Friday, December 21, 2018

Create new fields in standard table in business central 365 through AL VS code


Hello All,

Greeting!!

Hope you are well.


In previous post, we have covered first “Hello world” application in BC 365.
Now we will create extension here we will add new fields in standard table for this we need go to command palette and open workspace to add a new folder, this will also add two JSON files as explained in previous post i.e. app.json and launch.json.
If system does not create app.json file then you can create yourself by “Generate manifest”.
In addition, make sure to download symbol through command palette.











After that we create a new file with “Sales Header – Ext.al” file to create Sales Header table extension as per below screen shot. We did not get any problem or error in console.














So we will publish it after adding this fields to Sales order page. Now let’s create page extension, create a new field with “Sales Header page – Ext.al”.  


Now we are ready to publish our extension. After publish extension .app file will be created.
Let’s check on RTC that how our field look like on sales order page














In next post, we will how to add new table and pages.

Thanks.

Create your first application in Business Central 365 through AL Visual Studio Code.


Hello All,

Greetings!!
Hope you all are well.

Here we will create our first application in Business central using visual studio code in AL language.
For going forward we have minimum prerequisite for both cloud and on premises.

1. Window 10 Pro, Enterprise or Education edition
2. Business Central 365 on premises or Cloud
3. Visual studio code installed on machine

For more detail you can click below URL..
 https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/deployment/system-requirement-business-central

Here you see the Visual studio screen how it look like after installation




Now we need to install AL for this we need to click on Extension and the search for AL language.

After installing AL extension go to bottom at left side and click on setting icon then you will see command palette click it.


And now search for the "open work space" to add a project folder.
In an AL project there are two JSON files; the app.json file and the launch.json file. These files are generated automatically when you start a new project. The app.json file contains information about extension that you are building, such as publisher information and specifies the minimum version of base application objects that the extension is built on.


The launch.json file contains information about the server that the extension launches on.



After this will create standard extension for adding message on open of customer list as well on close page.

To create this we use code snippet which gives us a basic structure of object such as table, pages, codeunit etc. and their properties as well.
for this we have shortcut which are as below
Ctrl + space
t + space or t 
this will show you snippet to create your project.




As you can see after adding code we have published through VS itself to the BC server. we can also publish it by powershell will cover this on later.
For publish extension we use F5 with debugging and Ctrl + F5 with out debugging.
Let's check on the Business central RTC.. 




In next topic will cover how to add a new field on existing standard table.

Thanks.

How to Call an external API from NAV C/AL code

Hello All, Greetings! Hope you all are well. This post will cover how to consume external SOAP API and for this, we would u...