passing parameters to unknown report

Hello, I want to pass parameters to an unknown report. For example the user can fill in for the shipment agent the following (new fields) and if this shipment agent wants to have also the details, then this report is printed two times, the first time with only the bode and the second time with only the groupfooter. ----------------------- Table Shipment Agent: Report ID (integer) Also details (boolean) In a form I have the following code OrgAlsoDetails := “Also Details”; “Also Details” := FALSE; report.RUN(“Report ID”,FALSE,FALSE,Rec); // IF OrgAlsoDetails THEN BEGIN “Also Details” := TRUE; report.RUN(“Report ID”,FALSE,FALSE,Rec); END; In the report I have some code like this. body.presection: CurrReport.SHOWOUTPUT(“Also Details”) groupfooter.presection: CurrReport.SHOWOUTPUT(NOT “Also Details”); --------- This doesn’t work, because the programm runs first through the code in the form and after that it runs the report twice. which uses only the actual record. I also can’t use a variable type=report because I don’t know which report I have to use. Does anybody know a nice solution for this problem?

which version? >= 3.60: use a singleinstance-codeunit for storing and retrieving the values <=3.60: write to a table (but you will have to commit!), or write to a file in temp, and in the report if exists(‘c:\temp\rep0851’) then begin file.open(‘c:\temp\rep0851’); file.read(parameter); end;

Actually, SingleInstance Codeunits are available since Navision Financials 2.65.

I don’t think that this will work, because if you put it in a timeline then you get something like this. OrgAlsoDetails := “Also Details”; “Also Details” := FALSE; remember to run report.RUN(“Report ID”,FALSE,FALSE,Rec); “Also Details” := TRUE; remember to run report.RUN(“Report ID”,FALSE,FALSE,Rec); After the form has finished: the value of “Also Details” is TRUE and both reports run with this value Even if you put the parameter in an single instance codeunit or a file, you still have the same problem.

What if you do REPORT.RUNMODAL instead? As a side comment, I think your design is really confusing and you should look at other ways to work around this issue.

REPORT.RUNMODAL will definitely do the trick. Also it seems that you have forgotten a MODIFY before calling the report.

I now have this solution, and it works fine. But I don’t think this is a nice solution. So if anyone has a better idea, then let me know. This code is running from the OnPush method of a form and the table (Rec) is a new table called “Shipping List Header”. At this moment there is only one report which will be used for fax and/or email and this one can also be used for printing totals and/or details. So all the report ID’s have the same object nr. TempOrgShippingListHeader.DELETEALL; TempOrgShippingListHeader.INIT; TempOrgShippingListHeader.COPY(Rec); TempOrgShippingListHeader.INSERT; SETRECFILTER; ShippingAgent.GET("Shipping Agent Code"); //Fax the email IF ShippingAgent."Fax Shipping list" THEN BEGIN Vendor.GET(ShippingAgent."Vendor No."); IF Vendor."Fax No." = '' THEN ERROR(Text002); Fax := TRUE; "E-Mail" := FALSE; "Prt. Shipping List Detail" := FALSE; MODIFY; REPORT.RUNMODAL(ShippingAgent."Fax Report ID",FALSE,FALSE,Rec); IF ShippingAgent."Prt. Shipping List Detail" THEN BEGIN Fax := TRUE; "E-Mail" := FALSE; "Prt. Shipping List Detail" := TRUE; MODIFY; REPORT.RUNMODAL(ShippingAgent."Fax Report ID",FALSE,FALSE,Rec); END; END; IF ShippingAgent."Mail Shipping list" THEN BEGIN Vendor.GET(ShippingAgent."Vendor No."); IF Vendor."E-Mail" = '' THEN ERROR(Text003); Fax := FALSE; "E-Mail" := TRUE; "Prt. Shipping List Detail" := FALSE; MODIFY; FileName := STRSUBSTNO('\\Claudia-1\nav_dev\div\%1I.html',Vendor."E-Mail"); REPORT.SAVEASHTML(ShippingAgent."Mail Report ID",FileName,FALSE,Rec); Mail.NewMessage(Vendor."E-Mail",'',"Shipping List No.",'',FileName,FALSE); IF ShippingAgent."Prt. Shipping List Detail" THEN BEGIN Fax := FALSE; "E-Mail" := TRUE; "Prt. Shipping List Detail" := TRUE; MODIFY; FileName := STRSUBSTNO('\\Claudia-1\nav_dev\div\%1II.html',Vendor."E-Mail"); REPORT.SAVEASHTML(ShippingAgent."Mail Report ID",FileName,FALSE,Rec); Mail.NewMessage(Vendor."E-Mail",'',"Shipping List No.",'',FileName,FALSE); END; END; CLEAR(Rec); COPY(TempOrgShippingListHeader); MODIFY;

I know I said the design looked confusing, but hey! if it’s now working OK… don’t change it “just because” [:D]