Action scripts

Actions scripts are used to add logic to actions which can be executed for contacts, resources and search results. Optionally, actions can have condition scripts which determine the availability of the action. If a condition script is defined for the action, the action is only available if the condition script returns true.

Background knowledge about actions

Actions are available for three types of objects:

Actions for cases are called workflow activities. They are implemented in Scripts of the type Workflow.

Actions can be of the following types:

Manual actions can have forms which are opened when the user clicks the action in the Web Client. They need to be filled out to complete the action, see Control Forms.

Available action script types

The script type which is used for action scripts depends on the usage of the script. The following script types are available:

Logic of action scripts

The logic of an action script usually covers two aspects:

If the script is used as a condition script, its purpose is to determine whether the action is available or the action form is displayed.

Working with the current object

The object for which the action is executed is implicitly available in the script. This allows updating the object or performing any other relevant action. The following objects are available:

Defining the behavior after the action

In all action scripts, the behavior of the system after completing the action can be defined by using methods of the class OperationResponseBuilder. An object of this class, named client, is implicitly available in all action scripts, in automatic as well as in manual scripts. This object is also available in workflow scripts.

The client object includes methods for the following operations: 

Please refer to the ConSol CM API documentation for details about the available methods.

Coding examples

Opening the page to create a case

Use one of the following methods:

The following example opens the page to create a case. The queue “Helpdesk” is preselected and some fields are prefilled.

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

 

Ticket ticket = new Ticket();

ticket.setQueue(queueService.getByName("Helpdesk"))

ticket.setSubject("sample subject")

ticket.set("queue_fields.string", "test")

client.goToCreateTicket(ticket)

//to additionally set the main contact use withCustomer()

//client.goToCreateTicket(ticket).withCustomer(unit)

Code example 1: Open the page to create a case

Opening a case and displaying an activity form

Use the following method:

The following example opens the case with the name “100270” and directly opens the activity form of the Dismiss ticket activity.

client.goToTicket("100270").openActivityForm("defaultScope/Service_Desk/Ticket_dismissed/Dismiss_ticket_")

Code example 2: Open a ticket page with an ACF

Displaying messages in the Web Client

You can display messages with either a green or a red background.

The following methods display a message with a green background. The message text can be provided as a string or label:

The following methods display a message with a red background. The message text can be provided as a string or label:

By default, the methods to show messages do not refresh the page. Therefore, any updates to the object performed within the action scripts are not yet visible when the message is displayed. You can append withRefreshContent() to the method to refresh the page before showing the message:

client.showMessage("controlForm.info.executionOK").withRefreshContent()

The following figure shows a message with a green background: