Reports: Preventing a DataItem from running

PaLPiTaTioNPaLPiTaTioN Member Posts: 55
edited 2004-10-04 in Navision Attain
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

  • SteveOSteveO Member Posts: 164
    Try put the BREAK command on the PreDataItem of the Cust Ledg Entry
    This isn't a signature, I type this at the bottom of every message
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    SKIP and BREAK don't seem to do it.
    SteveO wrote:
    Try put the BREAK command on the PreDataItem of the Cust Ledg Entry

    It doesn't work.
  • Jelias1Jelias1 Member Posts: 35
    I would:
    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.
    :)
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    My problem isn't showing or not showing data. I could simply prevent the data from being outputted with the CurrReport.SKIP in OnAfterGetRecord. The issue is performance, because if I use SKIP, all records are evaluated, which takes a lot more time than just skipping a whole data item.
  • SteveOSteveO Member Posts: 164
    I have made the following report:

    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
    This isn't a signature, I type this at the bottom of every message
  • SteveOSteveO Member Posts: 164
    I have tried this in both 3.7 and 2.01A and both worked exactly the same.

    The BREAK seems to work just fine
    This isn't a signature, I type this at the bottom of every message
  • sggsgg Member Posts: 109
    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.

    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.
    Sunday, Godwin G
  • vaggelisvaggelis Member Posts: 3
    In the C/AL Globals create a boolean with the name "ShowDetails"
    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);
Sign In or Register to comment.