Create a scheduled job
Create a job that runs a server-side script on a schedule, such as a nightly count of resolved incidents.
Create a scheduled job when a server-side script must run on a timetable, such as every night. Use jobs for housekeeping and reminders that no user action triggers.
Before you begin
- You need the
administratorrole. - Switch to the Administration workspace with the Workspace selector at the foot of the menu.
- Have the script ready. Test a script that only reads records in System & deployment → Diagnostics → Server script, with Read-only on.
- Decide how often the job runs. Each run adds load to the instance.
- To deploy the job to another instance, create it in a change set. See Track changes in a change set.
Steps
-
Go to Scripting & automation → Jobs & generators → Jobs.

The Jobs item under Jobs & generators in the Scripting & automation menu. -
Select New.

The empty Create Job form, with Job name, Active, Cron expression, Description and Script. -
In Job name, enter a name that says what the job does, such as
Resolved incidents count. -
Next to Cron expression, select the asterisk icon. The Construct cron expression dialog opens.
-
Choose when the job runs on the dialog’s tabs and select Save. For 01:00 every day, select 00 under Specific minute(s) on the Minutes tab and 01 under Specific hour(s) on the Hours tab. The dialog writes
0 0 1 ? * * *to Cron expression.
The Construct cron expression dialog on the Hours tab, with 01 selected and the expression 0 0 1 ? * * * in the title. -
In Description, say what the job does and why.
-
In Script, enter the server-side script. This example counts the incidents that have been resolved for 14 days or more and writes the count to the system log.
Script
let cutOffDateTime = DateTime().minusDays(14); let waiting = 0; Table("Incident") .EQUAL("WorkflowStatus", "resolved") .LTE("CompletedAt", cutOffDateTime) .each(function(incidentRec) { waiting++; }); log.info("Resolved incidents count: " + waiting + " incident(s) resolved for 14 days or more"); -
Set Active to Yes and select Create.
Result
The job is in the job list and runs at each time its cron expression gives, in the instance time zone. A message the script writes with log.info() is in System & deployment → Logs → System log records after each run, with the Source DefaultLogger. A job whose Active is No never runs.