Record generator
Summary
The record generator functionality provides the ability to generate a sequential group of records that are related to a parent record based on a condition. This can be used to set up specific work records that when completed will trigger other work record(s) to be created, whilst populating a parent’s field upon completion. Whilst the record generator is associated to a record, the generated records are generated from the details set up in the associated record templates. It should be noted that only one record generator can be running against a record at once.
Record generator
Field | Type | Example | Notes / Description |
---|---|---|---|
Name | String | HR Case - Employee on-boarding | This is the name of the record generator used to identity a record generator. |
Active | Boolean | true | Highlights whether a record generator can run or not. |
Table | Table | HR Case | The Table that the record generator's condition will run on. Note that the record's generated do not have to be of the same Table. Currently only entities extended from Work are supported. |
Priority order | Integer | 1 | The priority order highlights what record generator will run if multiple have had their condition met at the same time. The lowest priority order will run in that situation. |
Condition | Condition builder | Classification is New employee > Onboard request | The condition as to when a record generator will run. If both this field and the advanced condition field have been entered, both fields need to pass the condition. Otherwise only the populated field needs to. |
Advanced condition | Script | //No scripted condition needed, just the classification | The condition that is required associate a record generator with a record. If the condition is scripted it requires an answer variable to be true or false. Within the script you have access to the current record it is executing on via "current". If both the advanced condition and condition field have been entered, both fields need to be true. |
On execution script | Script | 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();
} | This is the script that allows you to set any other field when the record generator is associated with a record. Within the script you have access to the current record it is executing on via "current". Do not update the record within the script, as it will automatically update if populated. This will populate the record that is triggering the record generator. |
Record templates | Related list [Record template Table] |
| The record templates that will generate the records as detailed within them when the record generator run. |
Record templates
Field | Type | Example | Notes / Description |
---|---|---|---|
Record generator | Reference [Record generator Table] | HR Case - Employee on-boarding | The associated record generator that will cause this record template to generate a record |
Short description | String | Request IT Hardware | This is the short description that is used when a short description field exists on the target record. It can be overwritten by the on creation script when required. |
Assignment group | Reference [Group table - must be selectable and accessible from the record template's table] | IT Service desk | This is the assignment group that is used when an assignment group field exists on the target record. It can be overwritten by the on creation script when required. |
Active | Boolean | True | Determines whether or not the record template will generate a record or not. |
Table | Table | ITSM Request | This is the record that will be created when required. It does not have to be of the same Table as the record generator. |
Related field | Choice [Fields on associated table] | Parent | This is the field on the Table selected that associates the record this template generates, with the record that the associated record generator is related to. For example; the parent incident field for incident tasks can be used. |
Wait for | Reference to many [Record template Table] | Internal services provisioning | These are the record templates associated with the record generator that need to be completed first for this template to generate a record. If there are multiple records here, they all need to complete prior to this record template is able to generate a record. |
On creation script | Script |
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());
}
current.ClientJournal("Welcome to Servicely! To proceed, please go to the <a href='/#/SelfService'> homepage</a> and type 'Request new hardware' to continue this process. When prompted, please enter the following number: " + current.Number() + ". Once completed, you will need to inform your manager, who will need to approve the request.");
current.update();
if (current.Parent().RequestedFor().Manager()) {
Table("WorkApprover").newRecord()
.Work(current.getID())
.User(current.Parent().RequestedFor().Manager().getID())
.create();
}
| This is the script that runs when a record is created from this record template. Within the script you have access to the current record it is executing on via "current". Do not update the record within the script, as it will automatically update if this field has been populated. |
Closure flag field | Choice [Fields on associated table] | Closed | This is the boolean on the record this template generates that highlights when it has been closed (to trigger the next record template records). |
Field to update on completion | Choice [Fields on associated table] | Client journal | If this has been populated, this is the field that will be updated with the content of the field below on the record that the generator is associated with. |
Content of completion update | Script | return "IT Hardware has been provisioned for " + current.RequestedFor().Name(); | This is the content that will be entered into the record that the generator is associated with, if the field is populated. Within the script you have access to the current record (that this template generated) it is executing on via "current". |
Records waiting for this template | Related list [Record template Table] | Read company policies | These are the record templates that will generate records, once the record that this record template has created has been closed. |
How record generators operate
When record generators have been set up for a Table, there is a specific run process in terms of how it runs. This section details what occurs and what steps take place to generate the associated records.
When a record has been updated, it will first determine if the record generator field has been populated. If it hasn’t, it will check if there are any active record generators associated with the Table that the record is updated that meet both the condition and advanced condition.
If there is one (or multiple), it will pick the one with the lowest priority order and populate the record generator field for that record.
Once done and there is an on execution script on the associated record generator, the on execution script will run against the record that started the record generator.
If it is the first time that the record generator is running against that associated record, it will generate a record for every associated active record template that has no “wait for” record template populated.
For each record template that is being generated, the short description, assignment group, related field and the record template field will be populated on the generated record. In addition to this, the on creation script on the record template will be run on the associated record it generates.
Once the required record templates have been run, the record generator will not run, until a record generated from a record template has been closed.
Once a record from a record template has been closed, it will populate the “field to update on completion” with the returned content from the “content of completion update” field on the record template that generated this record.
When this has been done, it will determine if there are any record templates that were waiting on this record to be completed, then begin those.
This process continues until all record’s have been closed.
It should be noted that once a record generator has been associated to a record, no others will.
Related content
Servicely Documentation