Progressive Number in NAV reports (NAV 2009 - NAV Classic)

Hello,

Please can you help me understand what is going on with my report. I don’t really get the point.

I have a report and the first column should generate a progressive Number ( 1,2,3,4,5,…)

What I have done:

  1. Create a global variable No.

  2. On Trigger OnPreDataItem() of the report i declare first No as zero:

No := 0;

  1. On OnAfterGetRecord() trigger i increment it by 1:

No := No + 1;

  1. Save and Compile

The result i get is as below: PS: A strange thing that i don’t get. Is not the first time I create a progressive no. In other reports the result is ok.

Progressive No.png

No way to know if you have other code that eventually prevents some records from actually being printed, which is executed after your counter?

If no break/skip in the OnAfterGetRecord, then check under the layout for the dataitem (OnPreDataItem).

First make sure No is not a field in the table from your driving table of your report that will completely throw off the report, declare a variable something like EntryNo, secondly you are incrementing the No OnAfterGetRecord which means no matter what your setrange condition is met or not it will increment the No. You will have to increment the No within your setrange which means only if the condition is met you are incrementing the No. Looks like when you are printing the record the variable No has run some many times that is why you are getting these weird nos.

The problem as I see is in grouping. In sections- In NAV 2009, I create a group footer to group the data.

Also in properties of table data item, i set the properties:

ReqFilterFields : Posting Date,Bill-to/Pay-to No.
GroupTotalFields: Posting Date,Bill-to/Pay-to No.

The problem that i sow is that also my progressive no ( 1, 2, 3, …) is grouping and is creating a mess.

But hwo to fi this? The same this i did in other reports and this situation did not happen.

Declare 1 variable called EntryNo or DocNo type Integer

OnPredataitem set Entryno or Docno to := 0;

Declare 2 variables PostingDate type Date and BilToPaytoNo Type code 20. On AfterGetRecord of the dataitem you will put a code

If (PostingDate <> record.Posting date) and (BilltoPaytono <> record.“bill-to/pay to no.” then

Entryno := Entryno + 1

On the last line of OnAfterGetrecord add the code

Postingdate := record.Posting date

BillToPayno := record.bill/to payno.

This way you are incrementing your entryno only when the group changes, otherwise don’t increment. Print your Entryno and then it will come in sequence.

Thank you so much @sbhatbng . It is ok now.

What I modified was just to use OR instead of AND.

Thank youuuuu :smiley: