Scripts of the type Default values
A default values script allows to preset values on the case creation screen in the Web Client and CM/Track. This saves time during the case creation as the users do not have to enter all the values. In addition, it is a way to indicate the most commonly used values in order to improve consistency. If required, the users can change the preset values.
Steps to use a default values script:
-
Write a script of the type Default values on the Scripts page.
-
Assign the script to the desired queue. Each queue can only have one default values script.
If you want to use the same default values script for several queues, you can use the queue parameter in the script code to implement specific values for each queue.
-
If you want to use the default values script in CM/Track, you need to set usePrefillScript to true in the config.json file of the client configuration, see Client configurations.
Coding example
The following example sets the default value for the priority field according to the client which is used to create the case: If the case is created in CM/Track, the default priority is high and if the case is created in the Web Client, the default priority is normal.
if (pClient == "track") {
ticket.set("helpdesk_standard.priority", "high")
} else {
ticket.set("helpdesk_standard.priority","normal")
}
Code example 4: Default values script with different values according to the client
The variable pClient can have two values:
- web: case created in the Web Client
- track: case created in CM/Track
Please keep in mind that in a default values script, you do not work in the workflow context. That means the workflowApi object (implementation of WorkflowContextService) is not available.
Overwrite mode for default values scripts
By default, default values scripts do not overwrite existing values. This means that there might be circumstances where not all values which are defined in a default values script are applied. If you change the queue of a case when some values are already set (by a default values script or manually), these values will not be overwritten by the default values script of the new queue.
You can change this behavior by enabling the overwrite mode. Add the following code at the beginning of the default values script to overwrite existing values:
import com.consol.cmas.common.model.ticket.TicketPrototypeContext
TicketPrototypeContext.enableOverwriteMode()