Due to various industry and customer requirements, I need to print the same information in different formats for the papaerwork packet that is included in shipments. I have the queries set up just fine with three different templates. But it seems kind of annoying that I have to run the report 3 different times for the three different templates when all three templates use the same data. Is there a method that I’m missing that somehow allows me to store the results of the queries and apply them to the three templates?
You can run a report multiple times with different templates programmatically using
ReportGuiManager.runReport(). There is a version of this method that receives
Thank you for the replay.
To be more specific, let us say I need to print 3 different templates (INVOICE_1, INVOICE_2, INVOICE_3) using the same data structure (same bands, same parameters,etc.). I know I can use the
runReport method 3 times. But what I am wondering is if there is a way to load the data structure once and then apply that data to the 3 templates. Be that by passing an array of templateCodes. Or loading the data structure, storing it as a local variable in the controller, then applying it to the 3 templates without requerying the database. I’m not sure of the internal data structure of YARG but I think it would be a trivial thing to return that internal structure.
A possibility is passing an instance of the
Invoice entity, but I haven’t been able to get that to work with my app’s data model. An
Invoice has many
InvoiceDetail references a
Product. But a
Product (with an attribute called
"name") also can be one of several subclasses (call them
DigitalProduct, with an attribute called
PhysicalProduct, with attributes for
dimensions). So passing in just an instance of the
Invoice entity, as I understand it, will only give me direct access to the
Product entity and not the
"dimensions", depending on which is applicable. So if there is a way to easily access those subclasses (again, without querying the database for the same data 3 times) then passing an entity instance could be the correct solution.