Show the first line if a invoice has more than a line
 
            
                
                    DarkHorse                
                
                    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.
                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.
0                
            Comments
- 
            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
 Albert0
- 
            nice0
- 
            More simple:
 Set the property "MaxIteration" of the DataItem to "1".0
- 
            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.)0
- 
            I think this is not what DarkHorse means.
 In this case shouldn't it something like that?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 OnPreDataItem of SalesInvLinex := COUNT; in OnAfterGetRecord of SalesInvLineIF 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."0
- 
            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?)0
- 
            @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. 
 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."0
- 
            Thanks everybody for help. I'll try all your replies.
 Thanks you very much.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 323 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions




