D365 Business Central Archives - Page 25 of 28 - - Page 25

Category Archives: D365 Business Central

Procedure to call an External API from Microsoft Dynamics NAV

Introduction: In this article, I will be giving the procedure to call an External API from Microsoft Dynamics NAV. The external API which I am going to call from Microsoft Dynamics NAV is ‘TIBCO Cloud Integration’ as I want to perform real-time integration between Dynamics NAV and Dynamics CRM. Pre-Requisites: 1. Microsoft Dynamics NAV 2. External API which will be called i.e. in this scenario, TIBCO Cloud Integration Mapping. Procedure: JSON syntax will be used for storing and exchanging data from Microsoft Dynamics NAV. I have created the following variables: ‘StringBuilder’ of datatype: DotNet and Subtype: System.Text.StringBuilder.’mscorlib’ ‘StringWriter’ of datatype: DotNet and Subtype: System.IO.StringWriter.’mscorlib’ ‘String Reader’ of datatype: DotNet and Subtype: System.IO.StringReader.’mscorlib’ ‘Json’ of datatype: DotNet and Subtype: System.String.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=***’ ‘JsonTextWriter’ of datatype ‘DotNet’ and Subtype: Newtonsoft.Json.JsonTextWriter.’Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=***’ ‘JsonTextReader’ of datatype ‘DotNet’ and subtype: Newtonsoft.Json.JsonTextReader.’Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=***’ I have created a function ‘Initialize’ which upon calling will initialize StringBuilder, StringWriter and JsonTextWriter variables as below: StringBuilder := StringBuilder.StringBuilder; StringWriter := StringWriter.StringWriter(StringBuilder); JsonTextWriter := JsonTextWriter.JsonTextWriter(StringWriter); I have created a function ‘StartJson’ where I am calling the ‘Initialize’ variables function and then calling the ‘WriteStartObject’ of JsonTextWriter DotNet variable. Now create a function ‘AddToJson’ which accepts two parameters as below: The first parameter accepts the name of the Scribe field mapping   i.e. name of the External API field mapping. The second parameter is the field value which is passed from Microsoft Dynamics NAV. Create another function ‘EndJson’ and call the ‘WriteEndObject’ as below:       JsonTextWriter.WriteEndObject; Create a function ‘GetJson’ where the JSon content is converted ToString.       JSon := StringBuilder.ToString; Next I have created a function ‘UploadJSon’ which will upload and POST the parameter values from Dynamics NAV. The UploadJson has the following parameters: The Subtype of DotNet variable ‘String’ is ‘System.String.’mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=***’ WebServiceURL is the URL which will be called, in this case I will be passing the Scribe map URL which will be hit on a particular condition to perform real time integration. I have created two local variables for the UploadJson function as below: ‘HttpWebRequest’ variable of DotNet DataType and SubType : System.Net.HttpWebRequest.’System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=***’ ‘HttpWebResponse’ variable of DotNet DataType and Subtype: System.Net.WebResponse.’System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=***’ The following code is written in the UploadJson function: The CreateWebRequest, SetRequestStream, DoWebRequest and GetResponseStream functions are as below: The CreateWebRequest accepts two parameters from which the second parameter is the HTTP request method i.e. ‘POST’ or ‘GET’. I have used ‘POST’ as this method submits data to be processed by a specified resource. You can set the timeout required during which the External API should be called. Now in my codeunit’s OnRun() function I have written the following code so that the External API URL i.e. Scribe map is hit and the real time integration between NAV and CRM takes place. I am passing five field values from Dynamics NAV. Note: AddToJSon(‘Car_Stage’,CarStageGlobal) where ‘Car_Stage’ is the name of the Scribe field mapping and ‘CarStageGlobal’ is the NAV field value. I have passed the Scribe map URL to UploadJson function and the Json DotNet variable. Conclusion: In this way, an External API can be called from Dynamics NAV. The External API URL i.e. Scribe map URL in this case is hit within seconds and real-time integration is performed quickly. The field values changed in Dynamics NAV are immediately reflected in Dynamics CRM.

Share Story :

To run a batch to check for visa expiry date of employees and send an email if visa expires in a month in Dynamics NAV

Introduction: This article focuses on to creating a batch to run everyday to check for employee’s visa expiry date. If the visa expires in a month an email notification is sent to the HR Manager about the visa expiry of the respective employee. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: Create a new codeunit with id and name. Set up the SMTP mail setup in NAV. 3. In the Globals (Ctrl+G),create a record for employee table. 4. Create a function and call it on run. 5. Here in the above code calculate the previous months date of the visa expiry date and if the the date is today then an email is send using smtp mail 6. Create a job queue to run every day. Set the start time and end time. 7. An email is sent if today’s date is the previous month date of visa expiry.  

Share Story :

Smart Notifications in NAV 2017

Partially built using the Notifications in the UI the smart notifications gives you advice when you use the application. As an example; if you create a new sales invoice for a customer that have an overdue balance you will see the below notification. Another example is when you close a sales order you receive a message saying that the order has not been posted (I am a bit skeptical to this one since in my world posting a sales order is not done by the same person that’s entering it). Luckily this is configurable and each user can turn the features off and on through the My Notifications setup where conditions also can be applied. I think this is a cool concept and I see a potential to create custom notifications to support how the business wants to operate and to reduce common user mistakes.

Share Story :

Export data to Excel in Dynamics NAV with Column captions using XML port

Introduction: With the help of XML port, it is possible to import and export data in Dynamics NAV. While exporting data to an Excel sheet, we always have a requirement to export data along with the column captions to an excel sheet. In this blog article, I will be explaining the procedure to achieve the same. Pre-requisite: Microsoft Dynamics NAV 2017 Procedure: Enter a node name. I have entered my node name as ‘Root’ with Node Type as ‘Element’ and Source Type as ‘Text’. For the caption names, first create a node with Node Type as ‘Element’ and Source Type as ‘Table’. Enter the Data Source as ‘Integer’ which is a virtual table in Dynamics NAV. Now enter a node name for your first caption name. In this example, I have entered ‘VINTitle’ as my first column caption name with Node Type as ‘Element’ and Source Type as ‘Text’. Go to C/AL code of ‘VINTitle’ which is my first node name and in ‘OnBeforePassVariable()’ write the code for the caption name that should appear in the Excel sheet when data is exported.This will display the name of the field which is entered in the table or you can also manually assign the name of the caption that should appear in the Excel sheet after exporting data as shown below. After the caption name is mentioned, now you have to enter the value which should be fetched from the table and appear in the Excel sheet. Enter the node name for your table with ‘Node Type’ as ‘Element’ and Source Type as ‘Table’. Enter your Data source. In this I have taken ‘Item’ as my Data source and the field ‘No.’ of Item table. Conclusion: After exporting data to an Excel sheet, the column captions appear in it along with the values of the column.  

Share Story :

Creation of a new Role Center and assigning it to a user as a profile in Microsoft Dynamics Nav 2017

Introduction: This article focuses on how to create a Role center page and assign the role to a user as a user profile. The requirement was such that the user needs a Role center for the HR where the HR can view the Active, Inactive and Terminated employees and can also view the List of employees, Leave application list etc. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1. Create a query with Data Source as Employee Table, create a filter field Status, here status is a option field which has three options -Active, Inative and Terminated.Create a column field and set Method type as Totals  and Method as Count. 2. Create a table with name e.g. HR Cue table. Here set the fields FieldClass to Flowfield and CalcFormula to Count. 3. Create a global function CountOrders and define the query in the variables. Here in the function, depending on the field number selected, it calls the query and sets the status to it. 4. To display Cues on the Role centre, we need to create a Page with Group subtype as CueGroup. 5. Use CueSetup codeunit for setting up cues and create an action Setup Cues. Create a local function CalculateCueFieldValues which checks if the field is active then it calls the global function CountOrders of HR Cue Page. 6. Create a Control Action as New Employee and set RunPageMode to Create and Run Object to Page Employee card. On running the cue Page 7. Create a new page for the Role Center with container subtype RoleCenterArea. 8. In Action Container subtype create HomeItems and add Action List. 9. In the Windows client, create a new Profile HR 10. Browse to the User personalization in the search bar in windows client , select the user HR and assign the HR Profile to it. 11. Log in to the Windows client/Web client.  

Share Story :

Dynamics Column reports in Navision 2017

Introduction: Many of client required report with dynamics Column in Navision. We all know dynamics data is displaying top to bottom. But what happen if customer want data left to right. And As data increase Column also increase in the report. In this blog, I will show you Item inventory report, where Item will display in row and location will display in Column. But when you add any new location in Navision and Post any Item Journal, sales, purchase  entry for that location, that new location will added in report Column. Steps 1: Open Navision Development Environment. Go to Object Designer.  And Create New Reports. For Demo I created New Report “ Item By Location New “ report ID 50029. Steps 2: GO to Design mode of that report. Take Item table in Data Item and Item Ledger Entry table in 2nd data Item. Relation set DataItemLink “Item No.=FIELD(No.)” in Item Ledger entry Property. Select the Column from the table. For the demo, I have taken only 4 fields, you can as fields as you’re your requirements. Steps 3: Go to view and and select Layout option. Here I am using SSRS Report Builder. Click on Insert , then click on Table button and select Table  Wizard Option. And select 1st option as per screen shots. Step 4: In Column groups click and drag Location code , for Row Group Item No. and in Value Sum of Quantity. Click on next and finish. Steps 5: Now add Item description fields on right side of Item. Step 6: Save the report and run. Click on preview. Steps 7 : Create new location and post Positive adjustment entry for that New location and again preview the report. New location is added in that report and its inventory Update. Conclusion :- With this method you can create dynamics column reports, which can be print left to right column.  

Share Story :

To restrict an action button to a particular user in NAV 2017

Introduction: This article focuses on how to restrict other users and allow only a particular user to user a specified action button in a Page in NAV 2017. The requirement was such that the page Purchase quote is to be signed off by the CEO and then Purchase order is created. Here, an action button is created called Sign off, where on click of the button, the boolean field called Sign off which is an un-editable field is enabled. Only the CEO should have the access to Sign off the Purchase Quote. The other users should be restricted from signing off the Purchase Quote Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1. In the NAV Development Environment, create a Boolean field. e.g CEO in the User Setup table. 2. Add this field to the User setup page and enable this field for the CEO user. 3. Create a button Sign off in the purchase quote. Create a new codeunit and subscribe it to the action button Sign off. 4. Create a global variable User Setup in the codeunit and refer the below code. 5. In the Windows client/Web Client, browse to Purchase Quote from the search bar. 6. Edit any Purchase Quote and click on Sign off. Here if the User is not the CEO, in the above image the user is OETIADMIN ,a message is displayed ‘Only the CEO can Sign off this purchase document’ 7. If the User is the authorize user to sign off in this case the CEO then the message is displayed as Purchase Quote is signed off.

Share Story :

Set up Single Sign-on in Dynamics NAV with Office 365 using Windows PowerShell

Microsoft Dynamics Nav integration is a default integration setup for Dynamics Nav that gives an option to integrate and use Microsoft Dynamics CRM entities with itself. The only thing that needs to be done for the integration is to enable the default integration setup after which you are good to go. After the successful integration, the user is able to integrate accounts, contacts, products, user, transaction currency, Sales Order which are synchronise data of Microsoft Dynamics CRM with the customers, contacts, items, Salesperson, Currency, Sales Order and Unit of measure which are the entities of Microsoft Dynamics Nav. This integration or linking of the records eases the process on many levels giving the customer a hassle free transaction and complex free system Introduction: Single sign-on (SSO) in Dynamics NAV is a process which authenticates a user to access NAV Web client and NAV windows client using Office 365 email login credentials. When a new Office 365 subscription is provisioned, the Azure AD tenant for this subscription has to be created. Pre-Requisites Microsoft Azure Active Directory Module for Windows PowerShell Microsoft Online Services Sign-in Assistant You can download the setup of Microsoft Online Services Sign-in Assistant from here Microsoft Dynamics NAV 2017 Purpose In this article, I will be explaining the procedure to configure Single Sign-on in Dynamics NAV with the Office 365 login credentials of a user using Windows PowerShell. Procedure: Go to Microsoft Dynamics NAV 2017 Administration and in the NAV instance enter the Certificate Thumbprint (the certificate can be either an SSL certificate or a self-signed certificate) Save the changes and restart your NAV instance. Go to mmc.exe and navigate to the certificate that is being used for Single sign-on. In mmc.exe, in Personal certificates section, in ‘Manage private keys’, add ‘NETWORK SERVICE’ as a user name and grant full control permissions to ‘NETWORK SERVICE’ user. In mmc.exe, along with Personal certificates section make sure the certificate is present in trusted root certification, Enterprise trust, Trusted publishers and Trusted people. Navigate to the user for which Single sign-on is being set up in NAV and under Office 365 Authentication enter the Office 365 email of the user.  Now run Microsoft Azure Active Directory Module for Windows PowerShell as administrator. Navigate to the Service folder to find NavAdminTool.ps1  module and run the following command in PowerShell to import the module Import-Module “C:\Program Files\Microsoft Dynamics NAV\100\Service\NavAdminTool.ps1” Navigate to the RoleTailoredClient folder to find ps1 module and run the following command in PowerShell to import the module. Import-Module “C:\Program Files (x86)\Microsoft Dynamics NAV\100\RoleTailored Client\NavModelTools.ps1” To import NAVOffice365Administration Module, navigate to the Microsoft Dynamics NAV DVD and then to NAVOffice365Administration. Run the following command in PowerShell to import NAVOffice365Administration.psm1. Import-Module “C:\Users\iotapadmin\Documents\CU 5 NAV 2017 W1\NAV.10.0.16177.W1.DVD\WindowsPowerShellScripts\NAVOffice365Administration\NAVOffice365Administration.psm1” To configure your Microsoft Dynamics NAV Server for single sign-on, you have to run the cmdlet  Set-NavSingleSignOnWithOffice365 in PowerShell with the following parameter set: Set-NavSingleSignOnWithOffice365 -AuthenticationEmail “YourAuthenticationEmail” -NavServerInstance “YourNAVServerInstance” -NavUser “YourNavUser” -NavWebAddress “YourNavWebClientAddress” -NavServerCertificateThumbprint “YourNAVServerCertificateThumbprint” -NavWebServerInstanceName “YourNavWebServerInstanceName” After entering this command a pop up box shown as below appears with the Office 365 email ID given in the above command and you have to enter the password of the given Office 365 email ID: After entering the password, the below output will appear in PowerShell: Copy and save the URL that appears at the end in PowerShell as it will be required later. Navigate to the ClientUserSettings file of the user and change the following parameters:Change ClientServicesCredentialType parameter value from ‘Windows’ to ‘AccessControlService’. Change the ACSUri parameter value to the value of URL link generated after the PowerShell command runs which I have mentioned in step 8. The parameters of the web client web.config file have not to be modified manually. It is automatically modified after the PowerShell command script runs. After SSO is configured, when you start Dynamics NAV Windows client and Web client, you have to enter the credentials of the Office 365 email ID which is provided while running PowerShell script in step 8. Fig: Windows Client Fig: Web Client

Share Story :

New fields in Sales & Receivable Setup in NAV 2017

As NAV 2017 introduced new features, they have added some fields in Sales & Receivable Setups. These fields are explained below : Following new fields are added in the Sales & Receivable setup as compared to NAV 2016. Default Item Quantity Create Item from Description Allow Document Deletion Before The functionality of these fields are explained below : Default Item Quantity : By default it will not be checked.  If the user checks it then, the default quantity in a sales line will automatically be set to 1 . (This will work only if the Type in the Sales Line is Item). Create Item from Description:  By default it will not be checked.  If the user checks it then, while entering Item description in Sales Line if the system is unable to find the same description in Item master, the system will prompt the user to create a New item or Select an Item From Existing List, as shown below. 3. Allow Document Deletion Before: If the date is provided in this field, system will allow to delete the document (Invoice & credit memo) only after checking the posting date which should be before the date provided in these field. This features might be very small but are very useful in day to day activities  by the user.

Share Story :

Purchase Quotation Dynamics NAV

Introduction: Purchase Quotation use to purchase items or services, and want to receive competitive offers from multiple vendors. In Purchase quote, vendors provide the prices and delivery times for the quantities of items that they specify. In the Search box, enter Purchase Quotes, and select the related link. Click on new to create new purchase quote. In the Buy-from Vendor No. field, select the vendor’s number. Select item in the type field in quote line. In the field, select the item number to be ordered. Enter the quantity you want to order in quantity field. Enter the Order date, Due Date, Expected receipt date on Purchase quote header. Once receive the price from vendor enter the price in Direct unit cost field. On Action tab click on Make order to create Purchase order from Purchase quote. You will get below Infolog when purchase order will be created. Conclusion: Purchase quotation is good feature in Dynamics NAV which allow you to create quote for items and services that you want to purchase from several vendors based on prices and time.  

Share Story :

SEARCH BLOGS:

[gravityform id="36" ajax="true"]

FOLLOW CLOUDFRONTS BLOG :