How to count record at second level of a report??

pedroccdapedroccda Member Posts: 90
How is possible to count record at second level?

If I have this structure in a report (12174-"Issued Cust Bills Report"):

- DataItem1 ("Issued Customer Bill Header")
- DataItem2 ("Issued Customer Bill Line")

How can I count DataItem2 items linked to DataItem1 before processing them ??

I thinked to use COUNT on DataItem2 in the trigger "OnAfterGetRecord" of DataItem1: firts I set the filter on dataitem2 using the link field between the dataitems ("Customer Bill No." = "No.") and then call FIND, but it gives an error (probably becouse I specify only 1 key of the 2 of DataItem2: I use only "Customer Bill No." but no "Line No."). But I can't know the second key ("Line No.") at prior.

Any idea??
Kiki

Comments

  • WaldoWaldo Member Posts: 3,412
    Isn't a COUNT OnPreDataItem of the second DataItem helping you?

    doing it your way should be fine as well ... appying the SETRANGE yourself. You don't need to call "FIND" though ... a count after the SETRANGE should be enough.

    I tested it in a codeunit:
    OnRun()
    recItem.SETRANGE("No.", '1000');
    MESSAGE('%1',recItem.COUNT);
    

    gave me a message:

    1

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.