Show the first line if a invoice has more than a line

DarkHorseDarkHorse Member Posts: 389
Hello, I have a report that shows the different lines from a document, an invoice for example.
I'd like to know how to show the first line only if that invoice has more than a line. I know its a little strange.
Thanks in advance.

Comments

  • AlbertvhAlbertvh Member Posts: 516
    hi,
    I assume that you have 2 DataItems
    SalesInvHeader
    --SalesInvLine

    in the OnPreDataItem of SalesInvLine
    x := 0;

    OnAfterGetRecord
    x := x + 1;
    IF x > 1 THEN
    CurrReport.SKIP

    x is defined as an integer


    Hope this helps


    Albert
  • EugeneEugene Member Posts: 309
    nice
  • toennetoenne Member Posts: 38
    More simple:

    Set the property "MaxIteration" of the DataItem to "1".
  • XypherXypher Member Posts: 297
    If you have referenced your DataItem(s) to actual (not Integer) Table(s) you can do the following...

    Of the DataItem/Table that contains the Invoice "line(s)" find the field that remains static or uniquely ties those records to their respective invoice. After you have found this field, apply it to the DataItem's 'GroupTotalFields' property. With this you can then insert a 'Group Header' section in your report with the following code behind it:

    (The following code would also be the most ideal method if you only have one DataItem; Where MaxIteration etc is not possible to be utilized)
    YourDataItem, GroupHeader (1) - OnPreSection()
    
      IF CurrReport.TOTALSCAUSEDBY = FIELDNO("Invoice ID Field") THEN
        //Do any calculations etc if you want a custom display
      ELSE
        CurrReport.SHOWOUTPUT(FALSE);
    

    Or if you just want it simple do..
    YourDataItem, GroupHeader (1) - OnPreSection()
    
      CurrReport.SHOWOUTPUT(CurrReport.TOTALSCAUSEDBY = FIELDNO("Invoice ID Field"));
    

    A 'Group Header' section will only trigger on the very first findings of the field(s) you have specified in the 'GroupTotalFields' property.

    (Important: This will *not* work if the implied field(s) do not have at least some method of sorting applied.)
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I think this is not what DarkHorse means.
    DarkHorse wrote:
    Hello, I have a report that shows the different lines from a document, an invoice for example.
    I'd like to know how to show the first line only if that invoice has more than a line. I know its a little strange.
    Thanks in advance.
    In this case shouldn't it something like that?

    In OnPreDataItem of SalesInvLine
    x := COUNT;
    
    in OnAfterGetRecord of SalesInvLine
    IF x <= 1 THEN
      CurrReport.SKIP
    
    and property MaxIteration of SalesInvLine set to 1.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • XypherXypher Member Posts: 297
    Yes if DarkHorse does in fact want to display only the first line of the "multiple lined invoices", einsTeIn.NET's example would work.

    But why go as far as putting code in two areas of the report if the previous area's code can be easily applied in the latter area:

    (MaxIteration = 1)
    DataItem - OnAfterGetRecord()
    
      IF COUNT = 1 THEN
        CurrReport.SKIP;
    

    ('OnAfterGetRecord' implies a record has been retrieve therefore you wouldn't need to specify '<=', correct?)
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    @Xypher:
    Yes, I thought it is better to count only once (performance), that's why in OnPreDataItem. But we only have one iteration, so it will count only once anyway. :lol:

    And yes, if there is no record the data item will not be executed. So = is enough.

    Very good annotation :!: =D>
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • DarkHorseDarkHorse Member Posts: 389
    Thanks everybody for help. I'll try all your replies.
    Thanks you very much.
Sign In or Register to comment.