I’m curious about your example of generating reports individually then combining them. your example function begins with the word “Do”, so I’m inferring that this is a server function. Please correct me if I’m wrong.
With on-demand reports, the server function is called to do the staging if needed, then either way, the report is actually generated inside the callback function. On demand report does not necessarily time out if I’m generating the full (largest) report. But this doesn’t guarantee that it won’t time out in the future as data grows.
Definitely this is an issue with generating emails with reports attached. In that case, the actual generating is controlled in a server function, and the executeAction is also called in the server function instead of from the client.
So now I’m wondering if I should create a new server function dedicated to generating a single report, then I can either call it from inside the callback function (if doing on-demand report). The problem is that we can’t call a server function from another server function. So I could make the final function to generate the single report into a library, that could be called from either client or server, called GenerateSingleReport.
This library could decide whether to iterate groups and generate a single report at a time then combine, or generate a full report. This decision can be based on a variable set from my ReportSettings table.
To do this, I would either need to create 2 different queries (one joining to SelectedGroups table, which is done currently, and one exactly the same but without using the join to SelectedGroups), then decide which one to use based on some metadata. But I believe that would require me to have 2 different report definitions, since the parameters are hard-coded in the report definition.
Alternatively, do you think I can somehow make the join in the query optional, based on a variable or something? That way I still only need a single report/query. But how, in five, would I do that?
Thanks for taking the time to read this post. I feel like we are getting closer…
UPDATE:
I figured out that I don’t need to change the query at all. When calling the report from client-side, just include all records based on the join with the SelectedGroups table.
When running the reports to attach to the emails, this is done server-side. There, I can control which of the originally selected records in the SelectedGroups table are selected. I’ve already written code that will snapshot the groups where IsSelected = true, then reset so only the desired group is selected, then run the report with the original query, then reset the SelectedGroups to where it was from the snapshot when I start the process. I’ve already tested that code, and it should work.
This lets me call the report from either client-side or server-side.
I need to verify the following:
- Is the report timeout you spoke of a problem when doing executeAction from client side as well as doing it from server side? I’ve run it from client side, and so far no timeout. But data can grow.
- Is the timeout avoided completely if I run the report for only 1 group, then combine when done?
- Can you verify the status of increasing the timeout, which you said was being worked on?
- Can you verify that if I use your sample code for printing one group, then combine the results when done, this must be done server-side instead of client side?
Thanks…