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.
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:
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.
An action can be of one of the following types:
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.
return actionScriptResultFactory.getPostAction(PostActionType.CREATE_TICKET, ticket, unit)
Redirects to ticket create page with fields filled with ticket data and existing unit as main contact.
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 67: Open the Create ticket page
Example:
UnitCriteria unitCriteria = new UnitCriteria();
Unit companyPattern = new Unit("company", customerGroup);
mdcmCriteriaBuilder.setReferencedCompanyCriteria(unitCriteria, companyPattern);
Code example 68: Open the ticket page in display mode
ActivityControlFormService.getExecutionContext(Ticket, String).
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 69: 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.
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 70: Unit execution script (customer implicitly available) to open the Create customer page
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 71: Unit execution script (unit implicitly available) to open a customer page in display mode
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 72: Open a Create resource page
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 73: Open a resource page in display mode
Example:
import com.consol.cmas.core.server.service.action.PostActionType
return actionScriptResultFactory.getPostAction(PostActionType.GOTO_PAGE, "http://consol.de");
For details, please refer to section Return Values and Return Messages.
For details, please refer to section 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 409: 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 410: 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:
action.result.success=Action succeeded
action.result.failure=Action failed
You can define your own labels for the display of messages in the Web Client. See section Labels for a detailed explanation.
Relation actions are available in CM versions 6.10.5.4 and up. They are available for all three main object types and are defined in the Admin Tool for the navigation items. Please see the detailed explanations in the respective sections of this manual.
A relation action is executed when the relation is
It is not executed when the comment of the relation has been changed.
Please note that a relation action is always executed when the object type for which the relation is defined is involved. As a consequence, two actions will be executed in case the source as well as the target object belong to a type with a relation action!
In scripts which define the relation actions, the following object are available:
Please note that in CM version 6.10.5.4, it is not possible within the relation action script to distinguish between a CREATE and a DELETE operation.
In the following example, the person who is the contact person for an SLA should receive an email whenever a new relation for this SLA to a customer has been established or has been deleted.
Steps to perform:
Example relation action script SLA_CompanyRelationAction.groovy:
import com.consol.cmas.common.model.mail.MailSendHolder
log.info 'SLA to company relation action has been triggered!'
def myUnit = relation.targetUnit
def myUnitDef = relation.targetUnit.definition.name
log.info 'myUnitDef is ' + myUnitDef
def nameField
def groupField
switch(myUnitDef) {
case "ResellerCompany": nameField = "company_name";
break;
case "company": nameField = "name1";
break;
case "DirCustCompany": nameField = "dir_cust_company_name"
break;
}
def myCustName = myUnit.get(nameField)
log.info 'customer name is ' + myCustName
def contPersMail = resource.get("SLA_Fields_basic.responsible_person_email")
if (contPersMail) {
log.info ' Email about SLA will be sent to ' + contPersMail
// Send an email asynchronuously. Mail object is not available outside workflow context!
def pResName = resource.get("SLA_Fields_basic.SLA_Name")
// alternative to fixed text: use text template
def pText = "A relation has been modified from resource " + pResName + " to company " + myCustName
def pTo = contPersMail
def pSubject = " new or deleted SLA relation - please take care"
def pHtml = false
def pFromEmail = configurationService.getValue("cmweb-server-adapter","mail.reply.to")
def holder = MailSendHolder.createSelfSendHolder(pText, pHtml, null, null)
holder.setSubject(pSubject)
holder.setTo(pTo)
holder.setFrom(pFromEmail)
mailService.sendMailAsynchronous(holder)
} else {
log.info 'No mail sent to SLA contact person, no email address found'
}
Code example 75: Relation action script to send an email when a resource-company relation has been created or deleted