Options

RTC filter transfer to Classic Report

RoelofRoelof Member Posts: 377
edited 2013-09-19 in NAV Three Tier
I'm having an issue with a classic report (report without RDLC), running in RTC. The report is called from a CodeUnit and using a 'MarkedOnly' filter set.

Lot.MARKEDONLY := TRUE;
PrintLotLabel(Lot);
.
.
PrintLotLabel(VAR Lot : Record "Lot No. Information")
REPORT.RUNMODAL(REPORT::"Lot Label",TRUE,FALSE,Lot);

In RTC, the report is losing all it's filters, set by MarkedOnly. I know RTC doesn't like MARKED and MARKEDONLY. Is there an easy workaround to transfer the recordset to the classic report from RTC?
Roelof de Jonghttp://www.wye.com

Comments

  • Options
    pdjpdj Member Posts: 643
    If the number of records is limited and the primary key is a single field, then there is a simple solution.
    Build a filter for the primary key like this "<primary key1>|<primary key2>|.."
    (Please ensure the primary key field doesn't contain any special filter chars: &, *, |, (, ), ?)

    Otherwise I guess you will need to press the magic button "Create Layout Suggestion" [-o<
    Regards
    Peter
  • Options
    RoelofRoelof Member Posts: 377
    Unfortunately that is not the case. The Primary key contains more fields.
    Would it be an option to transfer the subset of records (the data record is not large) to the Report using a function on the report? I'm not sure if a Classic Report in RTC likes that but any suggestion here?
    Roelof de Jonghttp://www.wye.com
  • Options
    Sam_MorrisSam_Morris Member Posts: 32
    Another thing you could try is to insert the records you want into a temporary table variable in the report, instead of pass the marked recordset. (You can set the record to be a temporary table be setting the property temporary = yes.) A new function in the report can be used to insert the records you want from the codeunit into the temp table. For example, your function in the report could be:

    InsertRecords(Lot : Record "Lot No. Information")
    tmpLot := Lot;
    tmpLot.INSERT;

    You can then call this function from your codeunit to insert the marked records. The below uses a report variable to call the function created above.

    // Lot filtered for marked only already
    IF Lot.FINDSET THEN
    REPEAT
    myreport.InsertRecords(Lot)
    UNTIL Lot.NEXT = 0;

    In your report you can now use this temp table to loop through the records. With dataitem of type Integer you can use something like the following to go through the records:

    Integer - OnPreDataItem()
    SETRANGE(Number,1,tmpLot.COUNT);

    Integer - OnAfterGetRecord()
    IF Number = 1 THEN
    tmpLot.FINDFIRST
    ELSE
    tmpLot.NEXT;

    All the table fields in the report need to point to the tmpLot table, and the data will be shown as normal.

    Lastly, you need to run the report from the codeunit using the report variable:

    myreport.RUNMODAL;
  • Options
    pdjpdj Member Posts: 643
    Roelof wrote:
    Unfortunately that is not the case. The Primary key contains more fields.
    Would it be an option to transfer the subset of records (the data record is not large) to the Report using a function on the report? I'm not sure if a Classic Report in RTC likes that but any suggestion here?

    No - that is not possible. You cannot call any functions on old reports, and I am almost sure you cannot call a report with a temporary record either.

    You could also create a new field on the table, and stamp a unique value (i.e. a GUID?) in it for the records you wish to print. Than you could set a filter, and cross you fingers that nobody else is trying to print any of the same records at the same time... (don't show the request form, as it will delay the print. Or have the report mark the stamped records in the OnInitReport)
    Regards
    Peter
Sign In or Register to comment.