Create a record from another record
Set up reclassification field maps and a table operation that creates or updates one record from another, such as a request from an incident.
Set this up when agents need a button that turns one record into another, or fills one record from another. The field maps decide what is copied, and a table operation runs the copy. Interactions already have this for every work type.
Before you begin
- You need the
administratorrole to create the table operation. Users withapplication_administratororconfiguration_administratorcan maintain the maps afterwards. - Know the source table and the target table by name, not label, for example Incident and ITSMRequest.
- Know which source fields go to which target fields. The names do not have to match.
Steps
-
In the Admin Console, select Administration → Configuration → Reclassification field map.
-
Create one map for each field to copy. Set Source table, Source field, Target table and Target field. Set Special type for journal, HTML and attachment fields. The fields are described in Reclassification field maps.
-
If the same pair of tables needs a second set of maps for another button, give those maps a Unique map name.
-
Select Administration → Business Logic → Table operations and create an operation on the source table. Set Operation type to Execute on server and choose where it shows. See Table operations.
-
In Server script, call
ReclassificationUtil.reclassifyRecordwith the source record, the source table and the target table. It returns the ID of the new record.var newRecId = ReclassificationUtil.reclassifyRecord(current, "Incident", "ITSMRequest"); answer = [{ id: newRecId }]; -
To apply only the maps of one Unique map, pass its name as a fourth argument.
-
In On success, open the new record with
Navigate.to({ urlElements: ["ITSMRequest", response.id, viewAspect] });. -
Save the operation and test it on a record in a test instance.
Result
The button appears on the source records. When an agent selects it, Servicely creates the target record with the mapped fields and opens it. Change the maps later to change what is copied, without touching the operation.
Variations
Update an existing record
To fill a record that already exists, pass the unique map, true and the target record’s ID. Servicely uses this to resolve a record on zero contact.
ReclassificationUtil.reclassifyRecord(current, "Incident", "ITSMRequest", "ZeroContactResolved", true, existingTargetId);
The arguments, in order, are:
- the source record
- the source table
- the target table
- the unique map, or
nullfor the default maps trueto update rather than create- the ID of the record to update