24 December 2016

Preview of Dynamics NAV Development Tools - How to get Started

I think most of you know by now already that Microsoft has released new Development preview for Dynamics NAV. If you still not updated on that yet, then refer below link on the Preview of Development Tools for Dynamics NAV

In this blog post we are going to talk about how to get start with new development tools. Currently all these tools are available in a Azure VM. Therefore we required to create a new VM in Azure. Microsoft has already created a deployment template for you and all you need to do is fill the blanks in the template. 

Once that is done it will automatically deploy the VM for you. So lets get started.. 

Step 01 : Create Azure Subscription 
If you does not have a Azure account then you can try the free account. To create a new free subscription refer below link : https://azure.microsoft.com/free/

Step 02 : Deploy Azure VM
Click on below link, which will take you to custom development template in Azure. While doing that it might ask you to login to your Azure Subscription. 

When the Deployment complete give it 10-15 min more until the Virtual Machine is initialized and VS Code has been installed and configured for you.

Step 03 : Connect to Virtual Machine
Select the Virtual Machine (Server1) like below and in next screen click on "Connect". Which will download the "Remote Desktop Connection"

Enter the "vmadmin" password to connect to Virtual Machine. 

Once you connect to Virtual Machine you can see the below Desktop Icons which will allow you to open Web Client of Dynamics NAV and Visual Studio Code. 

Stay tune for next blog post on how to use Visual Studio Code to develop extensions for Dynamics NAV and how to use Web Client to rearrange pages.  

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

20 December 2016

Preview of Development Tools for Dynamics NAV

Microsoft has deiced to give an early Christmas gifts to the world by introducing new tools to build extensions and apps in and for Dynamics NAV

Tool comes in two flavors and both are available in preview from today (21/12/2016).

The in-client designer
Before talking about it, just have a look at the below gif. I'm sure most of you will love the idea. No need to go back to developers to add a new field to a page. It is all can be done in the client window itself. 

This will allows to drag and drop interface, rearrange fields, rename-groups and reposition element to build perfect extension to support an industry-specific solution or implement a business process optimization.

Visual Studio Code
Use the AL Extension for NAV in Visual Studio Code to build powerful extensions based on tables, pages, and codeunits using the new objects: Page Extensions and Table Extensions. 

If you need to know how to start on using these great tools click here to access Microsoft official announcement.

The official short URL is : http://aka.ms/navdeveloperpreview

This looks so promising already and we are still at the preview.. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

11 December 2016

Understanding COMMIT and Transaction Scope within Microsoft Dynamics NAV

Have you tried and thought about what is the transaction scope. In this blog post I am going to discuss little bit about transaction scopes and how the transaction scope works within Microsoft Dynamics NAV. 

In order to check the simple scope I am planning to use below code. Pretty simple, its just inserting a record to Customer Table (T18) and trying to run a report using RUNMODAL

Even before we execute the code most of you knew what will happen if we try to run the above code. You will get most probably the largest or second largest error message in Dynamics NAV. 

What will happen if we add a COMMIT

It runs without any issue and open up the Report Request page as define in the code. What this means is that once the COMMIT is called it will end a write transaction scope.

Following is the definition for COMMIT in MSDN :
When a C/AL codeunit begins, it automatically enables write transactions to be performed. When a C/AL code module completes, it automatically ends the write transaction by committing the updates made by the C/AL code. This means that if you want the C/AL codeunit to perform a single write transaction, it is automatically handled for you. However, if you want the C/AL codeunit to perform multiple write transactions, you must use the COMMIT function to end one write transaction before you can start the next. The COMMIT function separates write transactions in a C/AL code module. (Link)
In simple COMMIT statement ends active Write Transaction. Refer below image to understand how the transaction scope is defined. 

Lets do a small change, 

When we run the code system throw out the Error message. Even though the error happen after the insert statement system rollback the transaction and move to the last system state. This is a one reason you never have to handle the transaction scope manually by you, NAV does it for you.  (Beautiful!)

Lets do another change to our code, I removed the error code and added new code segment. 

What will happen if we run this code? Wll get the same error what we received when we run the first segment of the code. However there is one small interesting thing in this code, to check that will open the RTC. 

Dynamics NAV has inserted the first customer record to the table and never rolled back even though the error has occurred. Reason behind that is can be understand easily by referring to below image :

Once we do a COMMIT manually, Dynamics NAV register those transactions in Database and never go back and undo the changes even though error occurs afterward. 

Therefore during the C/AL coding it is highly important to use COMMIT statement very wisely. If you use the COMMIT code without identify possible issues and identify them and handle them properly, your Database will end up with uncompleted transactions and then you might have to go and manually correct those records. 

Within Dynamics NAV Default Code: 
In some of the Dynamics NAV Default codeunits, COMMIT is been used inappropriate ways (my view), easiest example is in the Sales-Post codeunit. There are sevaral COMMIT statments within the codeunit which complex the process. 

As an example, system COMMIT after the Posting No. is assigned to a document and IF the document gets an error afterwards No. Series never get rolledback. If a user tried to delete the document then it will have a number gap in the posting documents. 

Reason behind COMMIT in the sales-post is to release the tables that was grabbed so that other posting routines can use those tables. There are ways around it and will discuss about those on futuer blog posts. 

Will the Temporary record works same with COMMIT? Await for next blog post.. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

10 December 2016

Overview of User Permission : Microsoft Dynamics NAV

During last few versions of Microsoft Dynamics NAV, Microsoft has introduced some cool new features. One of my favorite is user permission (It has a long way to go, but it is getting there) .

CRM and User Permission :
If you have worked with Microsoft Dynamics CRM you might have noticed how good (cool) is the user permission assignment in it. It is very easy and show the overall picture of how the user permission is assigned. (Below is a sample image of Dynamics CRM User Permission)

Pain with Dynamics NAV Permission :
During most of the implementations I have involved, we always got a complain that Dynamics NAV user permission is complex and is there way to do it much simpler way. Some of the cases we had to go for a add-on to ease the pain and most of the time company IT Admin had to live with the pain as the add-ons are much expensive. 

Main issue we faced is that Dynamics NAV did not had a central location to control the user permissions and also the way permission recording works. 

During last few release of Dynamics NAV product line, it seems Microsoft has identified the pain of IT Admins and they have come up with a much simpler solution to ease the pain. This may be not a perfect solution but we are almost there. 

Permission Sets :
If you navigate to Users  using department or using "Google Search" of Dynamics NAV, you can see few options on the ribbon. Today I will only go through the "Permission Sets" and will come back to "User Groups" on a different post. 

As a first step if you click on the "Permission Sets" it will open up a window with all the permission sets available in the Dynamics NAV. 

This is not new, this was always there (most of the versions) in Dynamics NAV. New about this screen is now you have a factbox or I would see Zoom-In box on the right side of the page. When you click on a permission set you can see the overview of the objects which are assigned to the selected permission set. 

Yes, it does not show the permission assign to each object, but if you want to see the well detailed version you can click on the "Permissions" button on the top of the ribbon. 

Details of the permission set include below details on the screen. It allows Admin to control what are the objects that user should have access and how the access should be. If a Admin required only to provide read permission to a object (depend on the object type), that control is available. 

Security Filter :
With the security filter Admin can apply a data based filter to the permission set. Check below example :

Ex : If a user should only see a invoices of one selected customer then Admin can add the Sales Header table and add appropriate data filters. Like wise many data filters can be applied and have a 100% control over the user permissions.

Permission Sets by User : Next lets check on my favorite functionality in the Permission Sets, which is "Permission Sets by User" 

This is a one perfect solution for a lack of "Permission Control Center" in Dynamics NAV. With this new feature Admin can see the complete overview picture of the companies assigned user permissions and more beauty is just with a click, admin can assign and remove a permission set from a user and does not have to go to each user profile and assign the permission like past.  Below is a sample of the "Permission Sets by User" control center. 

Below is the ribbon of the  "Permission Sets by User" control center and it allows to copy a permission set to a new permission set and also to view the detailed version of permissions. 

Hope you learned new things from the blog post or at least refresh your memory. 

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »

09 December 2016

December 2016 Cumulative Updates for Microsoft Dynamics NAV

Microsoft has published new Cumulative Updates for December 2016: Please refer below links for more information

If you had faced any trouble of copying a new company (Timeout the process after around 1 hour time) in a Azure hosted DB, then you might want to look at the CU Update 14 for Dynamics NAV 2016 and CU1 for Dynamics NAV 2017. 

In the current CU it will fix the the Import-NAVData cmdlet and it will require platform update. 

This will not fix the issue 100% but will fix half of the problem. Rest of the issue (Copy Company via Dynamics NAV) will be fixed most probably in the next CU update. 

It is always good to update your environment to latest Cumulative Update.

Please provide your feedback with a comment.
Thank you and Regards,
Tharanga Chandrasekara
Read more »

02 December 2016

Modern Dev Experience in NAV

It is a new chapter for Microsoft Dynamics NAV Community! 

Microsoft has released new AL language code samples for developing extensions on Dynamics NAV plaform. Thank you Microsoft Dynamics NAV development team for making this a sucess and releasing this early preview. 

Take a look at how a simple "Hello, World!" codeunit would look like in new syntax. (Ya ya.. Object IDs are still there)

 // ------------------------------------------------------------------------------------------------  
 // Copyright (c) Microsoft Corporation. All rights reserved.   
 // Licensed under the MIT License. See License.txt in the project root for license information.   
 // ------------------------------------------------------------------------------------------------  
 codeunit 70051001 HelloWorld  
   TableNo = Customer;  
   trigger OnRun();  
     HelloText : Codeunit GreetingsManagement;  
     Message(HelloText.GetRandomGreeting() + ', ' + Rec.Name);  

It looks very good and at the first glance codeing looks more like C#, which is good because it will attract new developers to the NAV world.

With new development experience we get a totally new file extention .AL

According to Microsoft, new VS Code development is used for extension development for Microsoft Dynamics NAV and also for Dynamics 365. This means at this stage we still have to stick with the existing Development Enviornment for all the other Dynamics NAV related developments. However in futuer Dynamics NAV Development Environemtn will say goodbye to the NAV world. 

You can access the new released code samples from below link: https://github.com/Microsoft/AL

Looking forward to play with Visual Studio development environment preview which may available for Christmas.

Rome wasn’t built in a day! But we are getrting there!

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara
Read more »