Scripts of Type Default Values
A default values script allows to preset values on the ticket creation screen in the Web Client and CM/Track. This saves time during the ticket 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.
The following figure shows the ticket creation screen with one preset field (HD priority). The other fields are empty.
Figure 396: ConSol CM Web Client - New ticket with default value
Steps to use a default values script:
- Write a script of the type Default values in the Scripts section of the Admin Tool.
- Assign the script to the desired queue (see Queues). Each queue can only have one default values script.
Coding Example
The following example sets the default value for the priority field according to the client which is used to create the ticket: If the ticket is created in CM/Track, the default priority is high and if the ticket 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 73: Default values script with different values according to the client
The variable pClient can have two values:
- web: ticket created in the Web Client
- track: ticket 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 ticket 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()