Skip to main content
Submitted by Suzanne Scanlan on 1 September 2017

ArcherPoint Dynamics NAV Developer Digest - vol 155Developer Dude

The NAV community, including the ArcherPoint technical staff, is made up of developers, project managers, and consultants who are constantly communicating, with the common goal of sharing helpful information with one another to help customers be more successful.

As they run into issues and questions, find the answers, and make new discoveries, they post them on blogs, forums, social everyone can benefit. We in Marketing watch these interactions and never cease to be amazed by the creativity, dedication, and brainpower we’re so fortunate to have in this community—so we thought, wouldn’t it be great to share this great information with everyone who might not have the time to check out the multitude of resources out there? So, the ArcherPoint Microsoft Dynamics NAV Developer Digest was born. Each week, we present a collection of thoughts and findings from NAV experts and devotees around the world. We hope these insights will benefit you, too.

Visual Studio Code 64-Bit Builds Now Available on Windows

They come in the Setup Installer as well as a ZIP archive. Get the details and ZIP files for Visual Studio Code 64-bit builds today.

Tips for Deleting All Records from a SQL Table

Saurav: Delete versus Truncate:

  1. Truncate does not create a log entry but delete creates a log entry
  2. Truncate can only be executed if there are no dependencies - Foreign Keys, Constraints, Views & References

So truncate is faster, but only if there are no constraints for the table.

Learning from Error Message while trying to use truncate from Dynamics NAV:

A call to System.Data.SqlClient.SqlCommand.ExecuteNonQuery failed with this message: Cannot TRUNCATE TABLE 'NavisionTest_CopyCompany.dbo.Cronus International$G_L Entry' because it is being referenced by object 'Cronus International$G_L Entry$VSIFT$1'.

Kyle: Said another way, Delete executes the SQL delete trigger for the table (if there is one) and truncate does not. Note that I am not talking about the NAV delete trigger, just the SQL delete trigger. For NAV tables, there won't be anything in the delete trigger.

Location Filter Not Working on Item Age Composition Report

Adrian Gan: For report 5807 "Item Age Composition - Qty.," the "Location Filter" does not work because it is a flowfilter while the field calculated in the report is not a flowfield. Any suggestions of making this filter work? Thanks in advance for your help.

Len: Adrian, looks like the report is doing what it was coded for. When you enter a Location Filter on the Item table, that filter is then transferred to the Item Ledger Entry table by the ItemLedgEntry.FilterLinesWithItemToPlan(Item,FALSE) which transfers the Location Filter into a filter on the Location Code on the Item Ledger Entry table. That means the Inventory Quantity is only including the Remaining Quantity from Item Ledger Entries that have a Location Code within the Location Filter you enter on the Item dataitem. I haven't tested the report, but it seems like it should work.

Adrian: Thanks Len. Where do you see the FilterLinesWithItemToPlan function? I don't see it in the report. The code looks right but I don't know why the location filter does not work on either my local machine or on the client site.

Len: Oops, I should have asked what version of NAV you were working in. I am working in NAV 2017. I went to all other versions and they are not written that way, they are all written as ItemLedgEntry.SETFILTER("Location Code","Location Filter"). It seems that if you change that code to ItemLedgEntry.SETFILTER("Location Code",GETFILTER("Location Filter")), you should be all set.

Adrian: Great solution! Thank you! Is that because Location Filter is a flowfilter on the item table rather than a normal field, so we need to use GETFILTER to retrieve the value of the filter?

Len: Exactly right!

Stay abreast of what is new in the Microsoft Dynamics NAV community and at ArcherPoint by subscribing to our monthly newsletter, Better Business, by completing the form in our Resource Center.

And, if you are interested in NAV development, be sure to see our collection of NAV Development Blogs.

Blog tags