We live in a world of global interaction, and this is reflected in the software that we use at work and at home. As expected this culture differences brings also more complexity and one more extra care for our development side. For instance, a Germany company that is now expanding its business to USA do need to take care of the cultural differences present on our system as date formats, number formats, and so on. Since in Germany we do for instance use the date as DD/MM/YY and in USA MM/DD/YY, we do have an issue when integrating those two systems.
So for such cases, in Microsoft Dynamics NAV 2013, Microsoft Dynamics NAV 2013 R2, and Microsoft Dynamics NAV 2015, you can set up the cultural settings so that our Microsoft Dynamics NAV system understands how to “translate” culture-specific data when exchanging data between the two countries.
Here below I show an example of how to configure and use Microsoft Dynamics NAV web services on different cultural environments (as I explained before I did this using the example of Germany and USA culture settings).
First lets discuss the necessary setup in Microsoft Dynamics NAV:
- In the CustomSettings.config file for the relevant Microsoft Dynamics NAV Server instance, add the following key:
<add key="ServicesCultureDefaultUserPersonalization" value="true"/>
- Make sure that the server where our middletier (the Microsoft Dynamics NAV Server instance) is running has the right regional settings.
Please do use the standard format Additional settings such as Decimal, and so on.
- Finally, in the Microsoft Dynamics NAV client, on the Personalization Card, set the relevant language for the Microsoft Dynamics NAV Server user - in this example Language ID 1031 for German.
For more information, see the Web Services and Regional Settings section here: https://msdn.microsoft.com/en-us/library/dd355398%28v=nav.80%29.aspx .
This finishes the setup part. Now we need to be sure that our VB application is using the correct code to “translate” the input date into the correct format when using Microsoft Dynamics NAV web services. This will indicates to our Microsoft Dynamics NAV Server how we do want to insert the date in our NAV database.
For this example I will take the Date and Decimal from our C# application project and convert them to pass the Data to Web Services that will finally “insert” it into our NAV System.
As for my setup in Microsoft Dynamics NAV, for this example I'm using the German language/cultural settings. In this example, I create a table and a page called WebServicesCultureTable and WebServicesCulturePage.
The page displays the following fields from the table:
Actually we will only use now the CultureCode ( the primary key), CultureDate that we will use to set the Date, and finally the CultureDecimal that we will use to check if the decimals are been passed correctly.
In the Visual Studio, in my C# project, I have created an application that can be used to insert the desired values for test.
So there I will use my web services to “pass” to Microsoft Dynamics NAV the date 11-08-15 (with the format) and the decimal 33.73M (we need this M so that C# understands that this is a decimal number). This class refers to a button in my C# application, but it resumes the necessary setting up for the Culture format that we need to use in order to our Web Server to understand correct the formats.
private void button3_Click(object sender, EventArgs e)
NavOData.NAV nav = new NavOData.NAV(new Uri("http://localhost:7148/DynamicsNAV71/OData/Company('CRONUS%20AG')"));
//Here define the companies, if need set a new company
nav.Credentials = CredentialCache.DefaultNetworkCredentials;
//Cultural Setting to Use on Date/Decimal
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE");
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE");
//Converting Cultural Date
String TESTDate = "11-08-15";
DateTime finalDate = DateTime.ParseExact(TESTDate, "DD-MM-YY", CultureInfo.CurrentCulture);
//Converting Cultural Decimal
decimal DecimalTEST = 33.73M;
System.Convert.ToDecimal(DecimalTEST, new System.Globalization.CultureInfo("de-DE"));
var WebServicesCultureTable = new NavOData.WebServicesCulturePage
//Here we can create new rows
CultureCode = "DE",
CultureDate = finalDate,
CultureDecimal = DecimalTEST,
Finally I inserted manually direct on the page the following test:
Then using my new button3 = Insert, I inserted the values to test on the web service side.
There you go: the culture personalization does works as desired!
Bonus info: This test I did using Microsoft Dynamics NAV 2013 R2 Cumulative Update 6 (build # 39665), but this functionality has been available since Microsoft Dynamics NAV 2013 Cumulative Update 9, and is also working as it should in Microsoft Dynamics NAV 2013 R2 and Microsoft Dynamics NAV 2015.
Daniel De Castro Santos Silva
Microsoft Dynamics NAV Support Engineer