March 2012 Entries
Flow Fields in Dynamics NAV

I don’t know the exact business reason but someone asked how to identify all sales shipping orders with any negative quantities on them.  They needed to print these separately from the shipments that only have all positive quantities.

Here is one way to solve this problem

In NAV, open Sales Shipment Header


Add a field of type Boolean (The field type should match the value you expect to return from the flow field method.  In this case we will use an exist so we expect a bool but we could have used a Sum, Average, Min, Max, Count, or a Lookup to return a value).


Define it as a flow field and click on the ellipse next to CalcFormula



Now [Has Negative Qty] is false if no negatives exist


And [Has Negative Qty] and true if a negative exist


So it is ready to be used as a filter on the report.


Don’t forget that if you are using it in code, you may need to CalcFields.

Hope that helps.  If you really can’t afford the field in your header, you can use code to check the lines for a negative value each time and use a skip or break function to skip that header record but it seems expensive to check them all if you only want a few to print.

Please let me know if you think of a better solution.