web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :

Expressions on Data Source column on NAV Reports

Nareshwar Raju Vaneshwar Profile Picture Nareshwar Raju Vane... 5,596

This post is regarding an error message that the Dynamics NAV could not trigger it on run-time.

I wrote the math expression right away on the Data Source column of a report object which as it is displayed on image 1a.

1

image 1a.

The math expression is: ROUND((SumOfScrap / “Capacity Ledger Entry”.”Output Quantity”) * 100, 0.01)

When I run the report, it loaded me the request page, but when I try to preview it, NAV did not give any sort of preview or error messages.

After analyzing the dataset, and I moved the math expression into theOnAfterGetRecord() trigger. When I run the report, NAV threw me an error as you can see on image 2b.

2
image 2b.

The reason for this error is, “Capacity Ledger Entry”.”Output Quantity” is 0in a few records of the dataset.

This is a basic level of error handling must have been considered, but NAV pointed me out when I added into a specific trigger, but not when it was a math expression on the Data Source column.

So I added a chunk of code assigning the math expression result to a decimal variable, in order to handle as simple as it can be.


//////////////////////////////////////////////
// Capacity Ledger Entry - OnAfterGetRecord()
///////////////////////////////////////////

IF "Capacity Ledger Entry"."Output Quantity" <> 0 THEN //to avoid the divide by zero exception
BEGIN
   WastageActual := ROUND((SumOfScrap / "Capacity Ledger Entry"."Output Quantity") * 100, 0.01);
END;

So, making a note to myself about sticking to the basics.


 



This was originally posted here.

Comments

*This post is locked for comments