Report Schedule Through Scripting

Is it possible to change a report schedule through scripting? This was asked a few years ago just checking to see if anything has changed over the versions.

No, there is not, but if you need dynamic scheduling (configurable at runtime by end users) I can think of a few ways to do it.

For instance, you could have a gateway timer script that runs e.g. once a minute, checks whether the current minute lines up with a scheduled time (in a database, perhaps) and then uses system.report.executeAndDistribute to generate your report dynamically.

Looking at that function it states that the thread could get blocked.

Is that also an issue when the reports are scheduled through the normal methods?

No, but you can always wrap your invocation of executeAndDistribute in system.util.invokeAsynchronous to run it on a new thread.

Do we need to do anything to clean up that new thread after the report is done running?

No. As long as the function provided to invokeAsynchronous exits, the thread will be automatically cleaned up. Just don't pass any custom functions with an infinite loop or similar.

That caution has been there for a while (pre-Perspective). If you run it in a Vision client without calling it through an asynchronous function, it would run in the GUI thread. That blocks anything else happening in the client until it was done.

Using a gateway scoped event, as mentioned by @PGriffith, you can set it to run in a dedicated thread.

1 Like