Scheduled Task

User guide · Administrator

Scheduled Task

Let OBS do things on its own, on a schedule: send reminders, move records to the next status, run reports and SQL. All scheduled tasks are in the module Main scheduler.

Main schedulerShow next runRun jobFunctions

Before you start

  • Main scheduler is for administrators. Open it from Quick access: type Main scheduler.
  • A task runs a function (what to do) with parameters (on what) at a time (when). Most functions need a name of a module, a column or an e-mail template: have them at hand.
  • Every change of a task ends with Save and then Show next run. A task without a next run will not start.

I want to…

The list of tasks

Main scheduler: next to the number of every task, the sliders (Show next run) and the clock (Show job history).
IconWhat it shows
SlidersShow next run: when the task runs next.
ClockShow job history: the last runs of this task, with status and error.

Create a task

  1. 1In Main scheduler click Create.
  2. 2Fill in Name and Description: write what the task does and for whom.
  3. 3Choose the Function and type the Parameters (see Functions).
  4. 4Set the time: Time zone, Start, End, the number of runs and the regularity.
  5. 5Tick Active and click Save.
  6. 6Click Show next run: you must see a date and time.

The fields

A task: the panel Functions (Show next run, Job execution log), the bar with History and Run job, and the fields in their groups.
Group on the formFieldWhat to enter
DescriptionName, DescriptionWhat the task does.
Select a function and activate the taskFunctionWhat OBS runs (see Functions below).
ParametersThe settings of the function, separated with |.
ActiveOnly active tasks run.
Select the time interval in which the task will be performedTime zoneThe time zone of Start, End and the hour, for example Europe/Sofia.
Start, EndFrom when until when the task may run.
Specify how many executions will be performedCount of executions (-1 = Unlimited)How many times in total; -1 means no limit.
Task RegularityExecute the task every …A number and a unit: Seconds, Minutes, Hours or Days.
Day of the monthOr: run once a month on this day.
At (Oclock)The hour and minute of the run.
NotificationsSend notification on executionSend an e-mail after each run.
Recipients (delimiter ;)The e-mail addresses, separated with ;. Some functions (RunReport) send their result to them.

Examples of timing

I wantSet
Every day at 08:00Execute the task every 1 Days, At 08 : 00, Count -1.
Every 15 minutesExecute the task every 15 Minutes, Count -1.
On the 1st of every month at 06:00Day of the month 1, At 06 : 00, Count -1.

Show next run

Click Show next run in the panel Functions on the left of the form, or the sliders icon in the list. For a few seconds, a message at the top right shows when the task runs next and how long until then.

Show next run: the date and time of the next run, and the time left.
Important
If Show next run shows no date, the task will not run. Check Active, Start and End, the count of executions, and save the form again (with the Save button on the form).

Did it run?

Click Job execution log in the panel Functions of the form, or the clock icon in the list: the last runs of this task.

The execution log of one task.
ColumnMeaning
Executed beforeHow long ago it ran.
Actual date and time of executionWhen it ran.
Function, ParametersWhat ran.
Status0 = no error.
ErrorThe error, if the run failed.

History in the bar above the form opens the module Scheduler log: every run of every task.

Good to know
Status 0 means the function finished without an error. It does not say how many e-mails were sent or how many records changed: check that in the module the task works on.

Run job

Run job in the bar above the form asks for a confirmation and runs the task once, now.

Important
Run job turns a repeating task into a one-time task and leaves it inactive. After Run job: tick Active, click Save, then Show next run, and check that the next date is right. Otherwise the task silently stops running.

Check in the execution log that the run really happened.

Functions

The functions used most, with their parameters. The parameters are separated with |; an empty place is left empty.

FunctionWhat it doesParameters
SQLFunctionRuns an SQL function of OBS. The function gets the ID of the task.function_name
RawSQLRuns an SQL statement.UPDATE tasks SET overdue = TRUE WHERE …
IssueProcessStepMoves records from one status to another and runs what the new step does (for example its e-mail; Work Flow).module|field|old step ID|new step ID|condition
e.g. timesheets|status_id|1|2|status_id = 1
SendReminderOverEmailAn e-mail some days before a date in a record.below
SendReminderOverEmail_AltThe same, to a fixed e-mail address.below
SendReminderOverEmailWithPDFThe same, with a PDF of the record attached.below
SendTheOutputOfFunctionToEmailRuns an SQL function that returns the columns html, recipients and subject, and e-mails the result.function_name
RunReportRuns a saved report of a module, saves it as Excel and sends it to the Recipients. Own text: an e-mail template named automated_report_<task ID>.the ID of the saved report (filter)
ProcessERPMailboxFiles e-mails to records (Email client).empty, or mt940|TEXT
ProcessInvoicesMailboxMakes expenses from PDF invoices in a mailbox (Email client).the folder (empty = INBOX)
RunFCMNotificationsPush notifications to the phones (Notifications).empty
SendChatMsgSends a chat message and a notification to the phone of the user.
IssuePostRequestSends a POST request to an API address.address|data
SQLViewRuns an SQL view and keeps the result in a table named after it.the view name without v$
Tip
Not sure which function to take? IssueProcessStep is best when the action already exists as a step of a process: the step sends the e-mail, the task only decides when.

Reminders before a date

SendReminderOverEmail looks at a date column in a module and sends an e-mail from a template to the person in a column of the record, a number of days before that date. It is the usual way to remind about ends of contracts, probation periods, deadlines.

PlaceParameterWhat to enter
1MODULEThe module (its name in the database), e.g. staff.
2FIELDThe column with the recipient: a reference to Employees or Contacts, e.g. manager_id.
3DATEThe date column, e.g. end_date.
4DAYSHow many days before the date the e-mail goes out.
5TEMPLATEThe name of the e-mail template (E-mail templates).
6CONDITIONOptional: which records, e.g. status_id = 2.
7POSTPROCESSINGOptional: what to change in the record after the e-mail, e.g. status_id = 3.

A real example: 14 days before the last working day of an employee, e-mail the manager with the template staff_departure_notification:

staff|manager_id|end_date|14|staff_departure_notification||
Good to know
DAYS can be negative: then the e-mail goes out after the date, for example -7 = a week after it.

To a fixed address: SendReminderOverEmail_Alt

The same, but the second parameter is a fixed e-mail address instead of a column, e.g. the HR mailbox:

staff|[email protected]|probation_end_date|14|end_of_probation_period_14|

With a PDF: SendReminderOverEmailWithPDF

The same parameters, and a PDF of the record is attached. The recipient column may point to Contacts, Users or Employees, or be a module of groups (e.g. invoices_groups). A real example: on the issue date, send the invoices in status 5 with the template send_invoice, then set their status to 2:

invoices|invoices_groups|issue_date|0|send_invoice|status_id = 5|status_id = 2

Tasks that work in pairs

Bigger notifications are often two tasks: one prepares the e-mails (an SQL function writes drafts) and one sends them (IssueProcessStep moves the drafts to the status that sends). Their names say so, for example … Generation and … Sending, and tasks that belong together share the start of the name ("Suite").

  • Keep both tasks active, and the sending one a few minutes after the preparing one.
  • If the preparing task did not run, the sending one has nothing to send: check the first one.
  • Example: the eSignature Automation Suite keeps electronic signatures in order (Digital Signature → Scheduled tasks).

FAQ

My task did not run.
Open it and click Show next run. No date: tick Active, check Start, End and the count of executions, Save, and Show next run again. A date but no run: look at the execution log for an error.
I clicked Run job and now the task does not run any more.
Run job made it a one-time task. Tick Active, Save, Show next run (Run job).
I changed the hour, but it still runs at the old time.
Save the form with the Save button and check Show next run.
Who gets Send notification on execution?
The addresses in Recipients, separated with ;.
Where are the older pages Automated tasks and SendReminderOverEmail?

Related: Notifications · Email client · Work Flow · Custom Reports.

Main scheduler: next to the number of every task, the sliders (Show next run) and the clock (Show job history).
A task: the panel Functions (Show next run, Job execution log), the bar with History and Run job, and the fields in their groups.
Show next run: the date and time of the next run, and the time left.
The execution log of one task.