Download Reportworq
⬇ Guide PDF

The Script Runner#

The Script Runner lets you attach .csx C# script files to a distribution job and choose which points in the execution pipeline each one fires at. A script receives the live workbook or presentation, the job's parameters, and the job result, so it can validate, reshape, protect or report on the output inside the run, before anything is distributed.

It is the in-process alternative to a VBA macro or an external post-processing pipeline. What leaves the building is already correct, rather than fixed up afterwards.

Scripts run on the Reportworq server. A script has access to local system resources through the account the Reportworq service runs as. Treat adding a script to a job the way you would treat any other server-side permission, and keep your .csx files somewhere with change control.

Licensing#

The Script Runner is part of the API license capability, the same one that enables the REST API and webhooks. There is no separate Script Runner entitlement, and the License Details view lists it as "API (includes Script Runner)".

If the license does not grant API:

If you need the Script Runner, ask for API on your license.

The six hooks#

Each hook blocks the pipeline: every script attached to it runs to completion before the job continues.

Hook Fires How often Can reach
Before Processing Before distributor pre-flight and any report calculation Once per job step Job metadata only
Before Calculation Before a report's data-source calculation Once per report The workbook
After Calculation After a report's data-source calculation Once per report The workbook
After Packet Generation After all reports are merged into the final workbook, before format conversion Once per job step The merged workbook
After PowerPoint After the PowerPoint file is generated Once per job step The presentation
After Send After every distributor has been called Once per job step The job result

Three things to hold on to:

Add a script to a job#

  1. Open the distribution job and open the Job Options sidebar.
  2. Scroll to Custom Scripts (Advanced). If you do not see it, the license does not grant API.
  3. Select Add Script.
  4. On the new row:
    • File: select the filename, or use Select Script... in the row's ... menu, to open the file browser and pick a .csx file. The picker shows all file types, because there is no .csx filter, so navigate to your file.
    • Hooks: use the multi-select to choose one or more hooks. A single script can fire on several, and it can tell which one it is in by reading HookName.
  5. Repeat for further scripts.

Scripts fire in list order within each hook. Use Move Up and Move Down in the ... menu to reorder. A row with no hooks selected never fires.

Validate before you run#

Validate in the row's ... menu compiles the script and reports either:

'filename.csx' compiled successfully.

or the list of compiler errors.

This checks syntax and types only. It does not execute the script, so a reference to a worksheet that does not exist, or a path that is wrong, still fails at run time. Validate catches typos, not logic.

Disable without deleting#

Disable in the ... menu skips a script at every hook while keeping its file and hook configuration. The row dims to show it is inactive. Enable brings it back. Use this rather than removing a row when you are isolating a problem.

Remove deletes the row outright.

Where scripts are stored#

A .csx is loaded through a source report provider, not from a server path. It lives wherever your report sources live, a network folder, SharePoint, Git, and it inherits that provider's access control.

That makes the provider worth choosing deliberately: whoever can put a file there can have it run. See Source report providers.

Reading the job log#

Every script execution writes to the job history log, prefixed with the hook and the row it came from:

[Script/AfterCalculation/#1 validate.csx] Executing script for job 'Monthly Sales', output 'Monthly Sales - East'.
[Script/AfterCalculation/#1 validate.csx] Script completed in 42 ms.

Anything the script logs itself, and any warning or error it raises, carries the same prefix. In a job with several scripts, the #N filename part is how you tell which row produced a line.

Script time also appears in a run's performance breakdown, so a slow hook is visible rather than mysterious.

What to watch out for#

Feedback on this page

Comments, questions, requests, or something missing or unclear? Email us - the page you are on is filled in for you.

Email feedback on this page

Or write to support@reportworq.com directly.