Wednesday, May 18, 2016

How Many Lines Can be Added In Between Records?

In my previous blog post I have discuss about AutoSplitKey function in Dynamics NAV. If you have missed that click here to open the previous blog post. 

I ended my previous blog post with a question and hope at least some of you have try and tested your answer in Dynamics NAV development. If not I will give you the correct answer to it. 

Let's just see a practical example of it using "Sales Line" table. 

As shown in the above image Dynamics NAV comes to a stage where system cannot be able to auto split the key for you. 

Let's now check what is the system limitation and logic behind it. 
Following is the sales line which used for previous example. As in shown in the previous image system does not allow users to enter any additional line between Line No. 10000 and Line No. 20000. To find out how many lines can be added and how the line is been split, I have copied the sales line to an excel. Please refer the below image. 
As you can see Dynamics NAV allows you to insert lines between two existing records and maximum no of lines you can add is 13. 

Reason for that is Line No. is the auto split field and since it is a integer variable, it cannot hold any decimal values. As you enter a record between Line No. 10000 and Line No. 20000; system will create a record and assign a Line No. 15000 to it. This goes to the point where Dynamics NAV could not create a new number in the integer level. 

Hope you have got the logic behind the AutoSplitKey and its limitations. 

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

AutoSplitKey

What is AutoSplitKey??
According to the MSDN, AutoSplitKey is defined as,
Sets whether a key is automatically created for a new record placed between the current record and the previous record.
This means when you enter a record in between two records, Dynamics NAV will split the last field of the primary key group and create a new value and assign to the newly created record. 
As an example if the user want to enter records between line 10000 and 20000 then system will split the line no (last primary key) as below. 
10000
10625
11250
12500
15000
20000

This is mainly used in the line tables where combination (concatenate) of fields been used as primary keys. 
If not for the inbuilt AutoSplitKey function in Dynamics NAV, developers will have to handle the auto split key option in the development level (with code level), which will be a headache in the production environment. 

Luckily the AutoSplitKey function is an in-built option and following are the main conditions must met to use the AutoSplitKey :
Let's just check how to set it..
As an example let's get the "Sales Line" (37) table and see how the primary key is been set. To do that just follow the steps according to the image below. 

Primary key of the "Sales Line" table : "Document Type,Document No.,Line No.". 
Last field of the primary key is set an integer and it fulfill the criteria required to use "AutoSplitKey" function.    

As the next step, open the properties of the page "Sales Invoice Subform" (47) using development environment. In the properties, go to AutoSplitKey and check the set parameter of it. In the "Sales Invoice Subform" it has been set to yes, which means key will get split automatically if the user will try to enter a line in between a record. 

Let's see how it works,
Hope above image does cover the practical aspect of the AutoSplitKey. 

Can you guess how many lines can be added in between two (02) records in Dynamics NAV? Just check my next blog post to get the answer on the question. 

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

Tuesday, May 17, 2016

Code Behind "How to Prevent Negative Inventory" - Versions After 2013

As mention in my previous blog post (How to Prevent Negative Inventory - Versions After 2013) Microsoft has added a option to prevent negative inventory in Microsoft Dynamics NAV. To find the code behind the validation I have import all the object files to "Statical Prism". Then I search for the Inventory Setup table which hold the field "Prevent Negative Inventory". Once the table is been identified in the field level I look for all the field usage. 

Here we go...
Code is in the Item Table under the function of PreventNegativeInventory
 PreventNegativeInventory() : Boolean  
 CASE "Prevent Negative Inventory" OF  
  "Prevent Negative Inventory"::Yes:  
   EXIT(TRUE);  
  "Prevent Negative Inventory"::No:  
   EXIT(FALSE);  
  "Prevent Negative Inventory"::Default:  
   BEGIN  
    InventorySetup.GET;  
    EXIT(InventorySetup."Prevent Negative Inventory");  
   END;  
 END;  

But this is not the complete one, we need to find other places where this function is been called. So I went back to "Statical Prism" and search for the PreventNegativeInventory function usage.

As shown in the above picture  PreventNegativeInventory function is called from Item Ledger Entry Table
 VerifyOnInventory()  
 IF NOT Open THEN  
  EXIT;  
 IF Quantity >= 0 THEN  
  EXIT;  
 CASE "Entry Type" OF  
  "Entry Type"::Consumption,"Entry Type"::"Assembly Consumption","Entry Type"::Transfer:  
   ERROR(IsNotOnInventoryErr,"Item No.");  
  ELSE BEGIN  
   Item.GET("Item No.");  
   IF Item.PreventNegativeInventory THEN  
    ERROR(IsNotOnInventoryErr,"Item No.");  
  END;  
 END;  

As in the code this is not the complete code, to find out the missing part open up the "Statical Prism" and search for VerifyOnInventory function usage. 

There you go, In the "Item Jnl.-Post Line" Code Unit under InsertItemLedgEntry function it calls for VerifyOnInventory function and it trigger the entire process. Following is the function code. 
 LOCAL InsertItemLedgEntry(VAR ItemLedgEntry : Record "Item Ledger Entry";TransferItem : Boolean)  
 WITH ItemJnlLine DO BEGIN  
  IF ItemLedgEntry.Open THEN BEGIN  
   ItemLedgEntry.VerifyOnInventory;  
   IF NOT (("Document Type" IN ["Document Type"::"Purchase Return Shipment","Document Type"::"Purchase Receipt"]) AND  
       ("Job No." <> ''))  
   THEN  
    IF (ItemLedgEntry.Quantity < 0) AND  
      (ItemTrackingCode."SN Specific Tracking" OR ItemTrackingCode."Lot Specific Tracking")  
    THEN  
     ERROR(Text018,"Serial No.","Lot No.","Item No.","Variant Code");  

Hope you got the code behind the prevent negative inventory option in Microsoft Dynamics NAV. 


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

How to Prevent Negative Inventory - Versions After 2013

In my previous blog post I have explained on "How to Prevent Negative Inventory" in the versions which came before Microsoft Dynamics NAV 2013 R2. In this blog post I will describe "How to Prevent Negative Inventory" in the versions which came after Dynamics NAV 2013. 

Luckily, Microsoft has finally added a control to validate the Dynamics NAV Negative Inventory. To activate the "Prevent Negative Inventory" option you required to follow below steps,
How to activate: 
  1. Go to Inventory Setup
  2. In that activate the "Prevent Negative Inventory"
Below image will show the steps you required to follow. 

Result:
To check the condition, I am going to post a sales invoice for a selected item which does not have sufficient inventory. 

It works fine and as it should be.. In my next blog post I will describe the code behind the modification.

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

How to Prevent Negative Inventory - Versions Before 2013 R2

In the Microsoft Dynamics NAV Community Forum many users post questions about how to prevent negative inventory. These questions are related with all the product versions in Dynamics NAV. This blog post will contain the information about "How to Prevent Negative Inventory" in Dynamics NAV. 

In the earlier versions (Before Microsoft Dynamics NAV 2013 R2) there were no option to prevent negative inventory at the time of sales. In earlier versions of Dynamics NAV block the transactions which match the below condition (Code Unit : Item Jnl.-Post Line ). 
 InsertItemLedgEntry(VAR ItemLedgEntry : Record "Item Ledger Entry";TransferItem : Boolean)  
 WITH ItemJnlLine DO BEGIN  
  IF ItemLedgEntry.Open THEN BEGIN  
   IF (((ItemLedgEntry."Entry Type" IN  
    [ItemLedgEntry."Entry Type"::"Negative Adjmt.",  
    ItemLedgEntry."Entry Type"::Consumption]) AND  
    ("Source Type" = "Source Type"::Item)) OR  
    (ItemLedgEntry."Entry Type" = ItemLedgEntry."Entry Type"::Transfer)) AND  
    (ItemLedgEntry.Quantity < 0)  
   THEN  
    ERROR(Text005,ItemLedgEntry."Item No."); 
That means all the sales related transactions are allows so the users can sell the goods to a client even if the stocks are not available in the system inventory. This sometimes create lot of inventory related issues in the company. Therefore many companies request partners to block the negative inventory in their system. 

How to do it in earlier versions :
Original Code :
 InsertItemLedgEntry(VAR ItemLedgEntry : Record "Item Ledger Entry";TransferItem : Boolean)  
 WITH ItemJnlLine DO BEGIN  
  IF ItemLedgEntry.Open THEN BEGIN  
   IF (((ItemLedgEntry."Entry Type" IN  
    [ItemLedgEntry."Entry Type"::"Negative Adjmt.",  
    ItemLedgEntry."Entry Type"::Consumption]) AND  
    ("Source Type" = "Source Type"::Item)) OR  
    (ItemLedgEntry."Entry Type" = ItemLedgEntry."Entry Type"::Transfer)) AND  
    (ItemLedgEntry.Quantity < 0)  
   THEN  
    ERROR(Text005,ItemLedgEntry."Item No.");  

Modification Required:
You required to add below lines of code to the "InsertItemLedgEntry" function in the "Item Jnl.-Post Line" Code Unit. 
// TC 02.201.2016
   IF (ItemLedgEntry.Quantity < 0) THEN  
    ERROR(Text005,ItemLedgEntry."Item No.");  
// TC 02.201.2016 End

Once the code is been added, function will be look like below
 InsertItemLedgEntry(VAR ItemLedgEntry : Record "Item Ledger Entry";TransferItem : Boolean)   
  WITH ItemJnlLine DO BEGIN   
  IF ItemLedgEntry.Open THEN BEGIN   
   IF (((ItemLedgEntry."Entry Type" IN   
   [ItemLedgEntry."Entry Type"::"Negative Adjmt.",   
   ItemLedgEntry."Entry Type"::Consumption]) AND   
   ("Source Type" = "Source Type"::Item)) OR   
   (ItemLedgEntry."Entry Type" = ItemLedgEntry."Entry Type"::Transfer)) AND   
   (ItemLedgEntry.Quantity < 0)   
   THEN   
   ERROR(Text005,ItemLedgEntry."Item No.");  
// TC 02.201.2016
   IF (ItemLedgEntry.Quantity < 0) THEN  
    ERROR(Text005,ItemLedgEntry."Item No.");  
// TC 02.201.2016 End

With the above two lines added to the existing code, Dynamics NAV will provide the required validation to prevent negative inventory. 
If you required to give a more dynamics control to the users, you can define a field in the Inventory Setup Table and  from that you can write the validation. With that your system administrator can change the condition dynamically. 

Result:

In my next blog post I will describe on how to do the prevent negative inventory in the Dynamics NAV 2013 R2, 2015 and 2016 versions. 

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

Monday, May 16, 2016

Cumulative Update 7 for Microsoft Dynamics NAV 2016 has been released (Build 45834)

Cumulative Update 7 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2016.


The cumulative update is intended mainly for solutions that are experiencing the problems described in the Knowledge Base article linked to below. However, you are advised to always keep your solution updated with the latest cumulative update. If you are in doubt about whether this cumulative update addresses your specific problem, or if you want to confirm whether any special compatibility, installation, or download issues are associated with this cumulative update, support professionals in Customer Support Services are ready to help you. For more information, see http://support.microsoft.com/contactus/.

The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:
AU – Australia
AT – Austria
BE – Belgium
CH – Switzerland
CZ – Czech Republic
DE – Germany
DK – Denmark
ES – Spain
FI – Finland
FR – France
IS – Iceland
IT – Italy
NA – North America
NL – Netherlands
NO – Norway
NZ – New Zealand
RU – Russia
SE – Sweden
UK – United Kingdom

Where to find Cumulative Update 7
You can download the cumulative update from KB 3157492 – Cumulative Update 7 for Microsoft Dynamics NAV 2016 (Build 45834).

Warning
Before you install a cumulative update in a production environment, take the following precautions:
  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.
Additional Information
For information about how to install the cumulative update, see How to Install a Microsoft Dynamics NAV 2016 Cumulative Update.

For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2016.

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

Cumulative Update 31 for Microsoft Dynamics NAV 2013 R2 has been released (Build 45822)

Cumulative Update 31 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013 R2.

The cumulative update is intended mainly for solutions that are experiencing the problems described in the Knowledge Base article linked to below. However, you are advised to always keep your solution updated with the latest cumulative update. If you are in doubt about whether this cumulative update addresses your specific problem, or if you want to confirm whether any special compatibility, installation, or download issues are associated with this cumulative update, support professionals in Customer Support Services are ready to help you. For more information, see http://support.microsoft.com/contactus/.

The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:
AU – Australia
AT – Austria
BE – Belgium
CH – Switzerland
CZ – Czech Republic
DE – Germany
DK – Denmark
ES – Spain
FI – Finland
FR – France
IS – Iceland
IT – Italy
NA – North America
NL – Netherlands
NO – Norway
NZ – New Zealand
RU – Russia
SE – Sweden
UK – United Kingdom

Where to find Cumulative Update 31
You can download the cumulative update from KB 3157488 – Cumulative Update 31 for Microsoft Dynamics NAV 2013 R2 (Build 45822).

Warning
Before you install a cumulative update in a production environment, take the following precautions:
  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.
Additional Information
For more information about cumulative updates for this version, see Announcement of update rollups for Microsoft Dynamics NAV 2013 R2.

For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2013 R2.

For a list of all hotfixes included in cumulative updates for this version, see the following CustomerSource and PartnerSource pages:

CustomerSource:

PartnerSource:

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

Cumulative Update 38 for Microsoft Dynamics NAV 2013 has been released (Build 45787)

Cumulative Update 38 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2013.

The cumulative update is intended mainly for solutions that are experiencing the problems described in the Knowledge Base article linked to below. However, you are advised to always keep your solution updated with the latest cumulative update. If you are in doubt about whether this cumulative update addresses your specific problem, or if you want to confirm whether any special compatibility, installation, or download issues are associated with this cumulative update, support professionals in Customer Support Services are ready to help you. For more information, see http://support.microsoft.com/contactus/.

The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:
AU – Australia
AT – Austria
BE – Belgium
CH – Switzerland
DE – Germany
DK – Denmark
ES – Spain
FI – Finland
FR – France
IS – Iceland
IT – Italy
NA – North America
NL – Netherlands
NO – Norway
NZ – New Zealand
SE – Sweden
UK – United Kingdom

Where to find Cumulative Update 38
You can download the cumulative update from KB 3157486 – Cumulative Update 38 for Microsoft Dynamics NAV 2013 (Build 45787).

Warning
Before you install a cumulative update in a production environment, take the following precautions:
  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.
Additional Information
For a list of all cumulative updates for this version, see Released Cumulative Updates for Microsoft Dynamics NAV 2013.

For a list of all hotfixes included in cumulative updates for this version, see the following CustomerSource and PartnerSource pages:

CustomerSource:

PartnerSource:

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

Cumulative Update 19 for Microsoft Dynamics NAV 2015 has been released (Build 41779)

Cumulative Update 19 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2015.

The cumulative update is intended mainly for solutions that are experiencing the problems described in the Knowledge Base article linked to below. However, you are advised to always keep your solution updated with the latest cumulative update. If you are in doubt about whether this cumulative update addresses your specific problem, or if you want to confirm whether any special compatibility, installation, or download issues are associated with this cumulative update, support professionals in Customer Support Services are ready to help you. For more information, see http://support.microsoft.com/contactus/.

The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:
AU – Australia
AT – Austria
BE – Belgium
CH – Switzerland
CZ – Czech Republic
DE – Germany
DK – Denmark
ES – Spain
FI – Finland
FR – France
IS – Iceland
IT – Italy
NA – North America
NL – Netherlands
NO – Norway
NZ – New Zealand
RU – Russia
SE – Sweden
UK – United Kingdom

Note: You must convert the database if you are upgrading to this cumulative update from a cumulative update earlier than Cumulative Update 9 (build 41779). For more information, see Converting a Database in Help for Microsoft Dynamics NAV.

Note: To enable customized translation of profiles, a number of actions are now available on the Profile List page. You can export and import resource files to enable translation for one or more profiles. The steps to install and uninstall language modules have also been modified. For more information, see How to: Install Language Modules, How to: Uninstall Language Modules, and How to: Export, Edit, and Import Translated Profile Strings in Help for Microsoft Dynamics NAV.

Where to find Cumulative Update 19
You can download the cumulative update from KB 3157490 – Cumulative Update 19 for Microsoft Dynamics NAV 2015 (Build 45813).

Warning
Before you install a cumulative update in a production environment, take the following precautions:
  1. Test the cumulative update in a non-production environment.
  2. Make a backup of the system or computer where the cumulative update is to be installed.
Additional Information
For information about how to install the cumulative update, see How to Install a Microsoft Dynamics NAV 2015 Cumulative Update.

For information about how to work around a recent process change, see How to Get Back the ‘Hotfix Directories’ from NAV 2015 Cumulative Update 1.

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

Tuesday, May 3, 2016

Shortcut Keys in Dynamics NAV 2016

The following shortcut keys are quite helpful, specially if you prefer using the keyboard instead of the mouse. You can definitely increase your work speed in daily doing using these shortcut keys and also it will look like you are an export on Dynamics NAV. :) 


Key
Event
Right Arrow
Move to the next field or character
Left Arrow
Move to the previous field or character
Up Arrow
Move to the field above in the same column
Down Arrow
Move to the field below in the same column
Delete
Clear selected text
Esc
Close the window or undo the data entry
End
Move to the last field on a line
Home
Move to the first field on a line
Tab
Move to the next field on non-line FastTabs
Enter
Move to the next editable field
F1
Open Help
F2
Edit
F3
Select Type to filter (field filter)
F4
Drop-down or look up to select
F5
Refresh the active window
F6
Go to the next frame
F7
Display statistics
F8
Copy the field above
F9
Post
F10, Alt
Select the menu bar and display access keys
F12
Select the navigation pane
Shift+F1
View error message
Shift+F3
Select Show Results (FlowFilter)
Shift+F4
Open a lookup window (from an ellipsis button)
Shift+F6
Go to the previous frame
Shift+F7
Open the related card
Shift+F8
Drop-down or look up to view
Shift+F9
Post and print
Shift+F10
Display a shortcut menu
Shift+F11
Apply entries, get source documents, or get warehouse documents
Shift+F12
Open the Role Center from the navigation pane
Shift+Tab
Move to the previous field
Shift+left-click
On multiple column headers, the columns will all be sorted in the same ascending or descending direction.
Shift+double-click
If sorting on multiple column headers using Shift+left-click, use Shift+double-click on the first column that was clicked on and this will toggle ascending/descending direction of all the columns included in the sorting.
Left-click
Left-click on a column header to sort a column ascending, then left-click again to toggle between ascending and descending.
Ctrl+F1
Collapse or expand the ribbon
Ctrl+F2
Create a new document
Ctrl+F3
Select Search pages
Ctrl+F4
Look up to the related list
Ctrl+F7
View entries
Ctrl+F9
Release document
Ctrl+F10
Select the ribbon and display key tips
Ctrl+F11
Reconcile or split lines
Ctrl+F12
Select the address bar
Ctrl+C
Copy
Ctrl+G
Go to
Ctrl+E
Export to Microsoft Office Excel
Ctrl+L
Show links
Ctrl+N
Create a new record
Ctrl+O
Open the company
Ctrl+P
Print
Ctrl+T
Select sorting
Ctrl+V
Paste
Ctrl+W
Export to Microsoft Office Word
Ctrl+X
Cut
Ctrl+Z
Undo
Ctrl+Page Down
Display next document or card in a list
Ctrl+Page Up
Display previous document or card in a list
Ctrl+Up Arrow
Move up while the selected line stays selected
Ctrl+Down Arrow
Move down while the selected line stays selected
Ctrl+Left Arrow
Move to the first field on a line
Ctrl+Right Arrow
Move to the last field on a line
Ctrl+Alt+F1
Open the About this Page/Report window (Zoom)
Ctrl+Delete
Delete the selected line
Ctrl+Home
Move to the first line in a list
Ctrl+End
Move to the last line in a list
Ctrl+Enter
Save and close window (equivalent to choosing the OK button)
Ctrl+Insert
Insert new line
Ctrl+Shift+F3
Select Limit totals to (table filter)
Ctrl+Shift+A
Clear all filters
Ctrl+Shift+C
Copy Rows
Ctrl+Shift+D
Show dimensions
Ctrl+Shift+E
Edit list
Ctrl+Shift+R
View list
Ctrl+Shift+Q
Collapse/expand a line in a hierarchy
Ctrl+Shift+V
Paste rows
Ctrl+Shift+W
Open a list place in a separate window
Ctrl+Shift+Enter
Save and close the window and open a new window
Alt
Display access keys in the ribbon
Alt+F2
Toggle to display/hide FactBoxes
Alt+F3
Filter to the value in the field
Alt+F4
Close window or close program
Alt+F6
Collapse or expand the active frame
Alt+F12
Optimize space for the current page
Alt+Left Arrow
Go to the previous window in the navigation history
Alt+Right Arrow
Go to the next window in the navigation history
Alt+Enter
Move to the field below without opening the drop-down menu
Alt+Tab
Toggle between open windows

Thank you jonathan archer for sharing the original article

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