Scripts of Type Default Values

Sometimes it is required that a data field of a ticket has a certain value when the ticket is initially created, i.e., when the engineer clicks New ticket and the respective form is opened in the Web Client, one or more values should be preset. This saves the engineer from having to set the value every time, e.g., when the default priority is normal, this can be preset. In case high or low is required, the engineer can switch to another value.

This ConSol CM behavior can be achieved by using one or more Default values scripts. The default values can be individually defined for each queue. For each queue, exactly one Default values script can be assigned. Please see the following example.

Figure 391: ConSol CM Web Client - New ticket without default values

Without a Default values script, no value is set for the priority when an engineer creates a new ticket in the Web Client.

To define a default value, a script of type Default values has to be created. First, we have to look up where the respective Custom Field is to be found (in which Custom Field Group and under which name) in the Custom Field Administration. See section Custom Field Administration (Setting Up the Ticket Data Model) for details.

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!

Figure 392: ConSol CM Admin Tool - Custom Field administration

Since priority is an enum field (i.e., an ordered list), we have to check the possible (technical) values which can appear in the list and we have to look for the required default value in the Enum Administration.

Figure 393: ConSol CM Admin Tool - Priority values in Enum administration

The group, the field, and the correct value can then be used in the respective Groovy method in the new script.

Figure 394: ConSol CM Admin Tool - Include group, field, and value in script

In the Queue Administration we have to assign the script to the queue where the default value should be used.

Figure 395: ConSol CM Admin Tool - Assign Default values script to queue in queue administration

When the engineer subsequently starts the create ticket operation in the Web Client, the default value normal will be set in the Priority field.

Figure 396: ConSol CM Web Client - New ticket with default value

Please keep in mind that for every queue there can be only one Default values script. If you have to define various default values, they have to be defined in one script. You might want to adapt the script name in this case, to better convey its intent.

If the same default value has to be set in different queues and is set together with other default values, this also has to be coded in one script for each queue.

Overwrite Mode for Default Values Scripts

By default, the fields of a ticket that are pre-filled by a Default values script are not overwritten, i.e., when the ticket is sent to another queue that has a different Default values script assigned, this second script will try to set fields that were already filled by the first script. Since this is not possible, the default value(s) from the first script are left intact.

If a Default values script should overwrite existing values, overwrite mode has to be activated. To activate this mode insert the following code at the beginning of your Default values script:

import com.consol.cmas.common.model.ticket.TicketPrototypeContext

TicketPrototypeContext.enableOverwriteMode()