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.
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.)
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."
@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."
Comments
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
Set the property "MaxIteration" of the DataItem to "1".
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)
Or if you just want it simple do..
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.)
In OnPreDataItem of SalesInvLine in OnAfterGetRecord of SalesInvLine and property MaxIteration of SalesInvLine set to 1.
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)
('OnAfterGetRecord' implies a record has been retrieve therefore you wouldn't need to specify '<=', correct?)
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>
Thanks you very much.