Clone scripts
Cases can be duplicated both in the Web Client and in CM/Track. The clone script assigned to the queue is executed in both clients.
When a case is cloned in the Web Client using the Clone button in the case header, the following data is transferred from the original case:
- case subject
- queue
- assignee (if set)
- values of all case fields in the header and details sections
- main contact
- additional contacts
The following data is not transferred from the original case:
- case history, including comments, emails and attachments
- participants
- related cases or resources
When a case is cloned in CM/Track using the Duplicate button in the case header, the following data is transferred from the original case:
- case subject
- queue
- values of all case fields in the header and details sections
- main contact
The Duplicate button is only available if the setting Show button for case duplication is set to True in the portal configuration.
A clone script allows you to overwrite the default behavior. You can use it to preset values in the newly created case, similarly to using a default values script. The user can change the values if required.
The variable pClient indicates the client in which the case is duplicated:
web: The case is duplicated in the Web Client.track: The case is duplicated in CM/Track.
You can use this variable to implement different behavior depending on the client.
Steps to use a clone script:
- Write a script of the type Clone on the Scripts page.
- Assign the script to the desired queue. Each queue can only have one clone script.
Coding example
In the following example, the clone script is used to reset the data field Desired deadline to avoid having incorrect deadlines in cloned ServiceDesk cases. It is only applied when the case is clones in CM/Track. If the script is assigned to the queue ServiceDesk, the field for the desired deadline is empty in the cloned case instead of containing the deadline from the original case.
if (pClient == "track") {
ticket.set("serviceDesk_fields.desiredDeadline", null)
}
Please keep in mind that in a clone script, you do not work in the workflow context. That means the workflowApi object (implementation of WorkflowContextService) is not available.