It is possible to define actions for search results. These actions are presented like workflow activities for result lists of
Search (result) actions operate on the result set of a search. You can configure search (result) actions to offer different bulk operations to the ConSol CM engineers, e.g., assigning all tickets in the result list to the current engineer (see the following figure), sending a specific email to all customers in the result list, or creating a new maintenance ticket for all PCs (resources) in the result list.
Figure 363: ConSol CM Web Client - Search actions for tickets
A search (result) action will be displayed in the Web Client only if
Each search action is implemented based on Admin Tool scripts of the following types.
Please note that the search action can be performed on
a) only the part of the result list which is displayed, e.g., on only 20 of 100 hits
OR
b) on the entire result list, e.g., on all 100 hits
The behavior of the search action depends on
Search actions are defined in the Admin Tool. You have to perform two or three steps to implement a search action, depending on the type of the search action.
Figure 364: ConSol CM Admin Tool - System, Scripts and Templates: Script for a search action for tickets
Example script:
// Assign all tickets in the result list to the current engineer
import com.consol.cmas.core.server.service.action.PostActionType
import com.consol.cmas.common.model.ticket.Ticket
def engineer = engineerService.getCurrent();
tickets.each { ticket ->
ticket.setEngineer(engineer);
};
return actionScriptResultFactory.getPostAction("success", "cmweb.search.assigned").withRefreshContent();
Code example 51: Search action script for tickets
For a detailed explanation about how to write scripts for the ConSol CM Action Framework, please read section Scripts for the Action Framework.
Figure 365: ConSol CM Admin Tool - Tickets, Search Actions: Defining a new ticket search action
Example script which sets the next maintenance date of all retrieved HP printers to a date in two weeks:
// Schedule maintenance date for all selected HP printers to a date in two weeks from today
import groovy.time.TimeCategory
import com.consol.cmas.core.server.service.action.PostActionType
println 'RUNNING Search action resources script!'
def now = new Date()
use(TimeCategory) {
nextMaintenanceDate = now + 2.weeks
}
resources.each { res ->
res.setFieldValue("HP_Printer_Fields_basic", "NextMaintenanceDate", nextMaintenanceDate)
}
return actionScriptResultFactory.getPostAction(PostActionType.SUCCESS, "cmweb.search.assigned").withRefreshContent();
Code example 52: Search action script for resources
For a detailed explanation about how to write scripts for the ConSol CM Action Framework, please read section Scripts for the Action Framework.
Figure 366: ConSol CM Admin Tool - Resources, Actions: Defining a Resource Search (Result) Action
Figure 367: ConSol CM Admin Tool - Resources, Actions: Assigning a search action to a resource type
Figure 368: ConSol CM Web Client - Search (Result) Action on resources, 1
Figure 369: ConSol CM Web Client - Search (Result) Action on resources, 2
Example action script which creates a ticket for each contact in the result list:
// For all contacts in the result set, a new ticket in the queue Service Desk will be created
import com.consol.cmas.core.server.service.action.PostActionType
import com.consol.cmas.common.model.ticket.Ticket
import com.consol.cmas.common.model.customfield.Unit
import com.consol.cmas.common.model.resource.*
import com.consol.cmas.common.service.resource.*
import com.consol.cmas.common.model.ticket.Queue
import com.consol.cmas.common.model.resource.meta.*
import com.consol.cmas.core.server.service.action.*
import groovy.time.TimeCategory
println 'Search Result Action Script CreateAnSDTicketForAllSelectedContacts STARTED ... '
// deadline is a required field in Service Desk tickets!
def now = new Date()
def deadline
use(TimeCategory) {
deadline = now + 2.weeks
}
Queue qu = queueService.getByName("ServiceDesk")
units.each{ cont ->
def cont_name = cont.customer_name
println 'Customer name is now : ' + cont_name
Ticket newtic = new Ticket()
newtic.setQueue(qu)
newtic.set("serviceDesk_fields.desiredDeadline", deadline)
newtic.setSubject("New Ticket due to Search Result for customer" + cont_name)
newtic.set("helpdesk_standard.priority","low")
ticketService.createWithUnit(newtic,cont)
println 'New Ticket created for customer ' + cont_name
}
return actionScriptResultFactory.getPostAction("success", "cmweb.search.assigned").withRefreshContent();
Code example 53: Search action script for units
Please make sure that
Example condition script which causes the Search (Result) Action to only be displayed if the list has more than five entries.
if (units.size() >= 5){
return true
} else {
return false
}
Code example 54: Search condition script for units
For a detailed explanation about how to write scripts for the ConSol CM Action Framework, please read section Scripts for the Action Framework.
Figure 370: ConSol CM Admin Tool - Customers, Actions: Defining a Unit Search (Result) Action
Figure 371: ConSol CM Admin Tool - Customers, Actions: Defining a Search Script Condition
Figure 372: ConSol CM Admin Tool - Customers, Customer Groups: Assigning a search action to a contact object within a customer group
Figure 373: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 1
Figure 374: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 2
The ticket list shows the new ServiceDesk tickets (1) which have been created in the Search Action script.
The following figure shows that the activity is not offered if the result list contains less than five entries (as defined in the condition script).
Figure 375: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 3
Some objects are implicitly available in the Admin Tool scripts, i.e., you do not have to import specific Groovy classes, nor do you have to instantiate such objects from a class.
Objects which are implicitly (without an explicit import or instantiation) available in Admin Tool scripts:
All search action scripts
Script types search action for tickets and search condition for tickets
Script types search action for resources and search condition for resources
Script types search action for customers and search conditions for customers
The search action can be performed on different interpretations of the result set. The behavior of the search action depends on the implementation of the Admin Tool script.
The search action can be performed on
a) only the part of the result list which is displayed in the Web Client, e.g., on only 20 of 100 hits. So this depends on the paging the engineer has selected and on the rows the engineer has selected if the row selection is switched on (see section Page Customization, enableRowSelection for details).
In the Admin Tool script, this is represented by the list of objects which is implicitly available, i.e., resources, tickets or units
OR
b) on the entire result list, e.g., on all 100 hits. This can be achieved by using the criteria object.
Use the general feedback component to handle the two new PostActionTypes: SUCCESS and FAILURE.
Example for a positive feedback:
return actionScriptResultFactory.getPostAction(PostActionType.SUCCESS, "cmweb.search.assigned").withRefreshContent();
Code example 55: Positive feedback
For a detailed explanation about how to write scripts for the ConSol CM Action Framework, please read section Scripts for the Action Framework.
Figure 376: ConSol CM Web Client - SUCCESS message after Search (Result) Action
Example of a negative feedback:
For a detailed explanation about how to write scripts for the ConSol CM Action Framework, please read section Scripts for the Action Framework.
Code example 56: Negative feedback
Figure 377: ConSol CM Web Client - FAILURE message after Search (Result) Action