Docs
On this page
reference1 min readApplication: Platform

Record generators

Fields of record generators and record templates, which create a sequence of related records for a parent record, and the order they run in.

A record generator creates a set of related records for a parent record when the parent meets a condition, for example the tasks of an employee onboarding case. Its record templates say what each record holds and which records must close before the next ones are created. This page is for administrators with the administrator role.

Record generators are under Administration → Configuration → Record generator. Only one record generator runs against a record. Generators work on tables extended from Work.

Record generator fields

Field Type Behaviour Purpose
Name Text Required. Identifies the generator, for example “HR Case - Employee on-boarding”.
Active Yes or no Only active generators run.
Table Table Required. A table extended from Work. The table whose records the condition is tested on. The generated records can be on other tables.
Priority order Number Default 0. When several generators match a record, the lowest number wins.
Condition Condition If Advanced condition is also set, both must match. When the generator applies, for example a classification.
Advanced condition Script Set answer to true or false. Receives current. If Condition is also set, both must match. Conditions a query cannot express.
On execution script Script Runs on the parent when the generator is attached. Receives current. Do not call current.update(): the record is saved afterwards. Sets fields on the parent, such as a journal entry.
Record templates Related list The templates the generator creates records from.

Record template fields

Field Type Behaviour Purpose
Record generator Record generator Required. The generator the template belongs to.
Short description Text Required. Copied to the new record’s short description field if it has one. The creation script can override it. Names the generated record, for example “Request IT Hardware”.
Assignment group Group Copied to the new record’s assignment group if it has one. The group must be selectable and accessible from the template’s table. Routes the generated record.
Active Yes or no Only active templates create records.
Table Table Required. The table of the record to create, for example ITSMRequest.
Related field Field Required. A field on Table. Links the new record to the parent, for example Parent.
Wait for Record templates Optional. All listed templates’ records must close first. Orders the records.
On creation script Script Runs on each record the template creates. Receives current. Copies details from the parent.
Closure flag field Field Required. A yes-or-no field on Table. Marks the generated record as closed, which releases the templates waiting for it.
Field to update on completion Field Optional. A field on the parent. Receives the completion text when the generated record closes.
Content of completion update Script Returns the text. Receives current, the generated record. The text added to the parent, for example a journal entry.
Records waiting for this template Related list The templates that wait for this one.
current.withTableChecks(TableChecks.DefaultChecks.withTriggersEnabled(false), () => {
    current.update();
});

See TableProtected and TableChecks.

How record generators run

  1. When a record is saved, Servicely checks whether a record generator is already attached. If not, it looks for active generators on the record’s table whose conditions match.
  2. If several match, it attaches the one with the lowest Priority order. No other generator is attached afterwards.
  3. The generator’s On execution script runs on the record.
  4. The first time, the generator creates a record from every active template with no Wait for templates.
  5. Each new record gets the template’s short description, assignment group and related field, then the On creation script runs on it.
  6. Nothing more happens until a generated record closes, as its Closure flag field shows.
  7. When one closes, the parent’s Field to update on completion receives the result of Content of completion update.
  8. Templates that were waiting for the closed record then create their records.
  9. This repeats until every generated record has closed.

Example: onboarding scripts

An On execution script on an HR case generator that writes to the requester and adds the requester’s manager as an approver:

current.ClientJournal("Thank you for raising this onboarding request. We will begin the process and inform you of the progress as each stage is completed.");
if (current.Requestor().Manager()) {
    Table("WorkApprover").newRecord()
        .Work(current.getID())
        .User(current.Requestor().Manager().getID())
        .create();
}

An On creation script on a template that creates an ITSM request and copies the parent’s contact details:

current.RequestedFor(current.Parent().RequestedFor().getID());
current.Requestor(current.Parent().Requestor().getID());
current.Email(current.Parent().Email());
current.Phone(current.Parent().Phone());
if (current.Parent().Location()) {
    current.Location(current.Parent().Location().getID());
}

A Content of completion update that tells the parent the hardware is ready:

return "IT Hardware has been provisioned for " + current.RequestedFor().Name();
Last updated 18 October 2026commit f37120b6b82bChris Jones
Back to top