Skip to main content

Ad hoc Queries in a Job

Adding an Ad hoc Query to a Job is similar to adding a Dataset, with one exception: an Ad hoc Query saves its results for only 60 minutes by default. The Query inside a Job therefore needs refreshing every time the Job executes, otherwise the Query stays empty and returns no data.

After adding an Ad hoc Query to a Job and clicking on it in the top-left, the display panel shows the words Run Query. Because an Ad hoc Query does not stay populated with data, the Query needs to run first inside a Job to preview the data before the Job runs.

An Ad hoc Query in a Job, with a Run Query button and a Will run as System Administrator label
An Ad hoc Query in a Job.

After clicking Run Query, the Ad hoc Query executes and the display panel on the right populates with data. Column order and Field settings are now available for customization (see Field options while viewing), and changes made here only affect the Ad hoc Query inside this Job.

Filters

To add post-query filters to a result set in a Job, click the + Filter option at the top. This is helpful when the returned result needs filtering before it goes out in an email or is written to a file.

An Ad hoc Query in a Job with the + Filter control highlighted above the result grid
Post-query filtering in a Job.

Reset Grid

When creating Jobs, you may reorganize the data held in the underlying Query. There are instances where you will need to reset the Query to its original state. To do so, use the Reset grid settings to those of the underlying Query button found on the data editor window.

An Ad hoc Query in a Job with the Reset grid settings button highlighted at the bottom right of the editor
Reset grid settings to those of the underlying Query.

Refresh

Manually refresh the Query by clicking the 3-dot action menu in the top right corner, then selecting Run. Notice the text displaying which User the Query will impersonate when running the Job. In the example below, that is the System Administrator User.

An Ad hoc Query in a Job with the Will run as System Administrator label highlighted
The Will run as information.

Because the System Administrator is also currently the owner of this Job, refreshing the underlying Query works as expected.

If you change the owner of this Job and then view this page again, an information banner appears across the top of the Query editor.

A blue banner reading Results are shown with your permissions and may vary from the actual results when the Job is run, with a Will run as Team A label
Information banner about Query results.

This banner lets you know that the results you see when running the Query here may differ from the results seen when the Job is run. This is because the owner of the Query is not the owner of the Job. Running the Query via the Run Query button refreshes the data with your permissions, which could differ from the permissions used when the Job is run.

When the owner of the Job does not have access to run the underlying Query at all, an orange banner appears across the top of the Query editor stating that the owner does not have adequate permissions to run it.

This can happen when a System Administrator creates an Ad hoc Query and adds it to a Job, then changes the owner of the Job to a normal User. Because the normal User does not have access to run that Ad hoc Query, the refresh fails when the Job is run.

An orange banner reading The owner of this Report does not have adequate permissions to run this Report, above an Ad hoc Query in a Job
Warning banner about Query results.

While editing the Job, if you want to change the owner of the Query, click the Will run as option. This opens a dialog that lets you change the owner of the Ad hoc Query to either yourself or the owner of the Job.

The Change Adhoc data provider owner dialog with options to Assign to myself or Assign to Job owner
Changing the owner of the underlying Query.
Also available through the REST API
Everything on this page is built on Informer's public REST API, the same one the product uses, so your scripts and integrations can do it too. Developer reference: Jobs.