Hi,
I have a report structure like
customer
cust. ledger entry
On the Request Form, I created a checkbox to let the user choose if he wants to see the records from Cust. Ledger Entry. This means that I should be able to prevent the Cust. Ledger Entry-dataitem from running at all.
I could use SKIP in OnAfterGetRecord, which would work, but would take lots of time. I could also use SetFilter in OnPreDataItem of Customer to make the recordset to skip less, which would make it all faster. But I cannot find the way to use OnPreDataItem (or the OnAfterGetRecord of the Customer table) to cancel the execution of the Ledger Entries dataitem.
does anyone know what I should do? SKIP and BREAK don't seem to do it.
Comments
It doesn't work.
1. Create one section (body or group section, depending on what you want to do) on the report that has the Cust. Ledger Entry fields you want to display.
2. Create one section of the same type that does not contain the Cust. Ledger entry fields.
3. Use the CurrReport.SHOWOUTPUT(chkBoxVal) on the sections to determine which section shows up.
If the checkbox is TRUE, the section will print. If it is FALSE, the section will not print.
I do this all the time to suppress printing of data depending on user needs.
Hope this helps.
Customer
Customer Ledger Entry (Linked by customer no = customer.no)
I have the following variable
skipcle : BOOLEAN
on Customer Ledger Entry.PreDataItem I have the following
if skipcle then
CurrReport.BREAK;
I have 2 bodies
Customer.BODY: Displays No. and Name
Customer Ledger Entry.BODY: Displays Entry No.
when skipcle = FALSE
I see all cle linked to the correct customers
when skipcle = TRUE
I only see customer no and name, no customer ledger entries
The BREAK seems to work just fine
of PreDataItem of the cust. ledger entry, you could add the following codes.
IF SkipDetails then "Cust. Ledger Entry".SETRANGE("Entry No.",0)
This way, the system will not enter into the Ledger Entry DataItem since there will be none there anyway.
Where SkipDetails is a Boolean Variable that you have placed on the Request Options Form of the Report.
NB: PrintOnlyIfDetail Property of the Customer DataItem MUST be set to NO Before This Works.
In the Request Form Designer create a checkbox with the label "Show Details".
In the properties window of the checkbox insert the value for the property SourceExp=ShowDetails.
In the Section Designer select the Customer Ledger Body and open the C/AL Editor.
In the OnPreSection Trigger put the following code:
CurrReport.SHOWOUTPUT(ShowDetails);