Thursday, May 31, 2018

API communication in MS Dynamics NAV 2018 Now Business Central.

Hi All ,

Once again I am getting stuck with calling of API in MS Dynamics NAV in my Germany office so I

thought why not get a dive into the sea of API. And lets check what it is in reality.

What is an API ?

Google says API is an Application Programming Interface. A way which provides us a facility to get 

data from another server.

But I cant understand now also. So lets get some diagrammatic view of an API.

I have a requirement from customer whenever a payment is done by a customer we need to check 

whether the customer has a credit balance to buy the article if no then send the notification to 

customer please contact the owner to increase your credit balance.

So here we were suggested to come with a solution of API we need to create one API which will be 

used by Paypal developers to checks whether this transaction is allowed or not.


I hope you got the point that what is an API.

API is generally a program written to say outer world that we will give you your data just send me 

the url for this requirement. In our example , my developed API will take the parameter of customer 

No. and will check in our customer table below points :

1. Customer Exist or Not.

2. If Exist , check the credit balance and proceed.

I hope concept is clear and requirement is also clear.

So what NAV developers will do now , we will create codeunit and will check the conditions and 

expose it to web service. But now we want to interpret with Paypal and they suggested API.

How to use API in NAV 2018?

First we will see how we can use then we will create API also.

Requirement from NAV Side :

1. Enable your NAV 2018 Admin for Soap and Odata Url.


If you want to go in more deep about API follow this video.




2. Search for API Setup page. Open it and click on Integrate API function it will populate all API present in NAV in Table API Web Service.  This is new system table.

3. We can check the data in Page but we need to create one page for this , as I had created this page on table API Web Service.
Please check how to create page on this table if you dont know in NAV from MSDN.


Lets Run this page.

You can create a web service for this page and check the data for this on browser.

The result of the data will be in JSON Format.

These are the following APIs provided by NAV 2018.


How to call API of NAV?

This is the URL provided by MSDN:

 http://<<Server Name>>:<<OData Port>>/<<Service Name>>/api/beta

For me its :

http://localhost:7048/DynamicsNAV110/api/beta

Hint : If you are not familiar with the url just open web service page and click on URL fields. There are 3 fields

ODATA V4 URL
ODATA URL
SOAP URL

With this you will get the desired URL for your system I followed the same.

After some time the result is as in Screen.


Now if its an API URL it should be present in POSTMAN. Lets check there also the result of our API  data is it available to other world.

For this I will write a new POST.

But I get 1 point now Microsoft is going to Business Central to a next Level of Data Library.

Friday, May 11, 2018

How to create New Nav Company using powershell?

Hi All,

Today I got one situation where we need to create a new NAV database from database itself and add the FOB and when we try to open it.

NAV will give us the ERROR 'No Company is found' or something like that.

So I interacted with powershell and sharing the basic steps to create Company in powershell if my nav developers get stuck in between.

SO lets start with powershell.

Step 1.

Open MS DYNAMICS NAV 2018 Administration Shell with Administrator Mode (Very important)

Import the Module using this command.

Import-Module "${env:ProgramFiles}\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1"


Step 2 .

Once it is imported Follow below screenshot :


It will take a while , if instance is running and everything works fine you can proceed with running your new company in RTC.

How to call stored procedure from MS Dynamics NAV 2018 using Automation Variable?


Automation Variable in NAV 2018

Frankly this is my first interaction with automation variable in my project. So I want to share with NAV community how can we connect our SQL Database and interact with stored procedures to process NAV database.

Step 1. Take the below variables.

Name                  DataType                          Subtype

lADOConnection Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Connection
lADOCommand Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Command
lADOParameter Automation 'Microsoft ActiveX Data Objects 2.8 Library'.Parameter
lvarActiveConnection Variant

Step 2. Write the below code :-

IF ISCLEAR(lADOConnection) THEN

CREATE(lADOConnection,FALSE,TRUE);

//lADOConnection.ConnectionString := 'Driver={SQL Server};Server=Server Address;Database=Database NAme;Uid=sa;Pwd=Password;

Check with other users also but provide some admin rights on SQL.

  lADOConnection.Open;

  IF ISCLEAR(lADOCommand) THEN
  CREATE(lADOCommand,FALSE,TRUE);
           
  lvarActiveConnection := lADOConnection;
  lADOCommand.ActiveConnection := lvarActiveConnection; 

  lADOCommand.CommandText := 'Stored Procedure Name';

  lADOCommand.CommandType := 4;
  lADOCommand.CommandTimeout := 0; 


  lADOCommand.Execute;

  lADOConnection.Close;
  CLEAR(lADOConnection);
  CLEAR(lADOParameter);
  CLEAR(lADOCommand);

 MESSAGE('Done Successfully');

So NAV Readers just try this code if you face any issue , comment below. Also for some usage bookmark this page.

Monday, May 7, 2018

Microsoft Dynamics 365 Apps Foundation

Dynamics 365 Apps For MS Dynamics NAV

Dynamics 365 is a online solution for end users with facilities of CRM and ERP. For NAV

 Developers how its going to impact is the one point of disscussion which we were disscussing in our

 Germany Office. So few things I liked that you can get from my this blog area.

This will clear all your understanding about Microsoft Dynamics 365.


Step 1.


Microsoft Dynamics 365 for Sales (popularly known as Dynamics CRM).

https://www.microsoft.com/en-us/dynamics365/sales




Step 2.


Microsoft Dynamics 365 for Field Service(popularly known as Dynamics CRM)


https://www.microsoft.com/en-us/dynamics365/field-service

Step 3.


Microsoft Dynamics 365 for Project Service Automation (popularly known as Dynamics CRM)


https://www.microsoft.com/en-us/dynamics365/project-service-automation




Step 4.


Microsoft Dynamics 365 for Finance and Operations, Enterprise edition (popularly known as Dynamics AX)


https://www.microsoft.com/en-us/dynamics365/operations


Step 5.

Microsoft Dynamics 365 for Finance and Operations, Business edition (also known as Project Madeira and based on popularly known Dynamics NAV)

https://www.microsoft.com/en-us/dynamics365/financials


Step 6.


Microsoft Dynamics 365 for Talent


https://www.microsoft.com/en-us/dynamics365/talent


Step 7.


Microsoft Dynamics 365 for Retail


https://www.microsoft.com/en-us/dynamics365/retail

Step 8.


Microsoft Dynamics 365 for Marketing


https://www.microsoft.com/en-us/dynamics365/marketing


Step 9.


Microsoft Dynamics 365 for Marketing


https://www.microsoft.com/en-us/dynamics365/marketing


Step 10.


Microsoft Dynamics 365 for Customer insights


https://www.microsoft.com/en-us/dynamics365/customer-insights