Scripts for the Action Framework

Introduction

The ConSol CM Action Framework offers the ability to start actions which are not related to workflow activities, i.e., they can be started or triggered in another context, not only in a workflow context.

The Action Framework consists (as of ConSol CM version 6.10) of three components which are treated in the respective manual sections in detail.

In this section here, you will learn more about Action Framework-specific programming.

Admin Tool Scripts for the Action Framework

Script Types

Each action is based on an Admin Tool script as described in the sections mentioned above. For each Admin Tool script, the correct script type has to be set.

Please note that for each execution script, a condition script can be defined. It has to be associated with the execution script in the action definition in the Admin Tool. This condition script will be executed before the execution script.

Thus, the execution script will only be executed if either

or

The following Action Framework-related script types are available:

Script Return Values

The return value of a condition script has to be either true or false.

The return value of a manual execution script has to be one of the following PostActionTypes:

Please see the details in the following section.

Action Types

An action can be of one of the following types:

Programming with the Action Framework

One core component of programming scripts for manual actions in the ConSol CM Action Framework is the class ActionScriptResultFactory. An instance of this class is available as actionScriptResultFactory in each execution script. The type of the returned PostActionScriptResult, i.e., the PostActionType, defines the step directly following the execution of a manual execution script. You can implement the desired system behavior using the PostActionType.

Open the Create Ticket Page

Example:

import com.consol.cmas.core.server.service.action.PostActionType

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")

ticket.set("queue_fields", "boolean", "true")

return actionScriptResultFactory.getPostAction(PostActionType.CREATE_TICKET, ticket)

//to additionally set main contact use

//return actionScriptResultFactory.getPostAction(PostActionType.CREATE_TICKET, ticket, unit)

Code example 61: Open the Create ticket page

Open the Ticket Page in Display-Only Mode

Example:

UnitCriteria unitCriteria = new UnitCriteria();

Unit companyPattern = new Unit("company", customerGroup);

mdcmCriteriaBuilder.setReferencedCompanyCriteria(unitCriteria, companyPattern);

Code example 62: Open the ticket page in display mode

Open the Ticket Page in Display-Only Mode and Show ACF Before

Example:

(...)

 

def executionContext = activityFormDefinitionService.getExecutionContext(newtic, "defaultScope/TaskInProgress/AcceptTask")

if (!executionContext) {

return actionScriptResultFactory.getPostAction(PostActionType.FAILURE, "action.fail.wrong.activity")

}

 

// Modify entities from the execution context - not the original ones

// - since the user may still press cancel.

executionContext.ticket.add("SpecialTasks_Fields","Deadline", new Date());

 

return actionScriptResultFactory.getPostAction(PostActionType.GOTO_TICKET, newtic, executionContext);

Code example 63: Open the ticket page in display mode and show ACF before

Please note that the implementation class for the bean activityFormDefinitionService is ActivityControlFormService. Please refer to the class documentation for details. In scripts, access is by its bean name, as in the script above.

Open the Create Unit (Contact or Company) Page

Example:

import com.consol.cmas.common.model.customfield.Unit

import com.consol.cmas.core.server.service.action.PostActionType

 

Unit contact = new Unit("customer", unit.getCustomerGroup());

contact.set("firstname", "Luke");

contact.set("name", "Skywalker");

return actionScriptResultFactory.getPostAction(PostActionType.CREATE_UNIT, contact);

Code example 64: Unit execution script (customer implicitly available) to open the Create customer page

Open a Unit (= Customer, i.e., Contact or Company) Page in Display-Only Mode

Example:

import com.consol.cmas.common.model.customfield.Unit

import com.consol.cmas.core.server.service.action.PostActionType

 

Unit contact = unitService.getByCustomerGroup(unit.getCustomerGroup()).get(0)

return actionScriptResultFactory.getPostAction(PostActionType.GOTO_UNIT, contact)

Code example 65: Unit execution script (unit implicitly available) to open a customer page in display mode

Open a Create Resource Page

Example:

import com.consol.cmas.common.model.resource.Resource

import com.consol.cmas.common.model.resource.meta.ResourceType

import com.consol.cmas.core.server.service.action.PostActionType

 

ResourceType type = resourceTypeService.getByName("resource type 1")

Resource resource = new Resource(type)

resource.setFieldValue("group1", "stringField1", "value1")

resource.setFieldValue("group2", "numberField1", 1L)

return actionScriptResultFactory.getPostAction(PostActionType.CREATE_RESOURCE, resource)

Code example 66: Open a Create resource page

Open a Resource Page in Display-Only Mode

Example:

import com.consol.cmas.common.model.resource.Resource

import com.consol.cmas.core.server.service.action.PostActionType

 

Resource resource = resourceService.getAll().iterator().next()

return actionScriptResultFactory.getPostAction(PostActionType.GOTO_RESOURCE, resource);

Code example 67: Open a resource page in display mode

Open a URL

Example:

import com.consol.cmas.core.server.service.action.PostActionType

 

return actionScriptResultFactory.getPostAction(PostActionType.GOTO_PAGE, "http://consol.de");

Code example 68: Open a URL

Display Result Message in Web Client: SUCCESS

For details, please refer to section Return Values and Return Messages.

Display Result Message in Web Client: FAILURE

For details, please refer to section Return Values and Return Messages.

Return Values and Return Messages

To indicate the return value of a ConSol CM action for the engineer in the Web Client, you have to use one of two PostActionTypes:

You have to set a return value for every execution script. It is not possible to end an execution script without the return value (a run-time error will be thrown in that case).

Example of a positive feedback:

return actionScriptResultFactory.getPostAction(PostActionType.SUCCESS, "cmweb.search.assigned").withRefreshContent();

Figure 339: ConSol CM Web Client - SUCCESS message after Search (Result) Action

Example of a negative feedback:

return actionScriptResultFactory.getPostAction(PostActionType.FAILURE, "cmweb.search.assigned").withRefreshContent();

Figure 340: ConSol CM Web Client - FAILURE message after Search (Result) Action

The text which is displayed (e.g., Action succeed or Action failed) can be retrieved using one of two methods:

CM Standard Values for Return Messages

action.result.success=Action succeeded

action.result.failure=Action failed

Use System-Specific Labels

You can define your own labels for the display of messages in the Web Client. See section Labels for a detailed explanation.