---
title: "Record generators"
site: admin
version: 2027.1
versions: "all"
url: https://docs-new.servicely.ai/admin/2027.1/automation/record-rules/record-generators/
type: reference
application: platform
last_updated: 2026-12-03
commit: 6777698daac5
---


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.

In the Administration workspace, go to **Scripting & automation → Jobs & generators → Record generator**. Only one record generator runs against a record. Generators work on tables extended from Work.

<Image src="asset:screenshots/admin/automation-record-rules-record-generators/record-generator-menu.png">The Record generator item in the Jobs & generators section of the Scripting & automation menu.</Image>

## Record generator fields

<Image src="asset:screenshots/admin/automation-record-rules-record-generators/new-record-generator.png">The empty Create Record generator form, with the Condition, On execution and Record templates tabs.</Image>

| 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. |

<Callout type="warning">
  Calling `current.update()` in an **On creation script** runs the new record's triggers a second time, which can send duplicate notifications. Save with triggers turned off instead, as shown below.
</Callout>

```javascript
current.withTableChecks(TableChecks.DefaultChecks.withTriggersEnabled(false), () => {
    current.update();
});
```

See [TableProtected and TableChecks](page:api/scripting/records/table-checks).

## 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:

```javascript
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:

```javascript
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:

```javascript
return "IT Hardware has been provisioned for " + current.RequestedFor().Name();
```

## Related

- [Reminder generators](page:automation/record-rules/reminder-generators)
- [Checklists](page:automation/record-rules/checklists)
- [Script libraries](page:automation/scripts/script-libraries)
- [TableProtected and TableChecks](page:api/scripting/records/table-checks)
