Running a report with parameters from another report/codeunit

I have a report that takes a location code, start date and end date on the request form. It works just the way I want. But now I want to automate emailing this report. My only hangup is how I can pass the parameters to the report from another report.

Report 50058 is the detailed report that takes 3 parameters, two dates and a location

Report 50059 is the wrapper report that will loop through all locations and then email the first report. I can get it to email fine, I just need to know how I can pass the parameters to the report so when I export it as HTML it is location specific. Does that make sense? Here is the overview of what I’m doing.

Loop through the location

Run report 50058 with the location code

Email the report

Keep looping until I’m done

I’m looking for something like this


I know it won’t be that easy but if you could point my in the right direction. Thanks!

Before running the report 50058, create a function in report 50058 like initialize and pass the variables from 50059…

Ex. 50058.initialize(loccode,startdate,enddate);

in 50059, you can assign these paramaters to 50059 report variables and use them…

Awesome! Thank you so much!