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 e-mail to all customers in the result list, or creating a new maintenance ticket for all PCs (resources) in the result list.
Figure 346: 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 347: ConSol CM Admin Tool - Script for a Bulk Ticket Action
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 48: 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 348: ConSol CM Admin Tool - 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 49: 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 349: ConSol CM Admin Tool - Defining a Resource Search (Result) Action
Figure 350: ConSol CM Admin Tool - Assigning a Search Action to a Resource Type
Figure 351: ConSol CM Web Client - Search (Result) Action on resources, 1
Figure 352: 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 50: 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 51: 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 353: ConSol CM Admin Tool - Defining a Unit Search (Result) Action
Figure 354: ConSol CM Admin Tool - Defining a Search Script Condition
Figure 355: ConSol CM Admin Tool - Assigning a Search Action to a contact object within a customer group
Figure 356: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 1
Figure 357: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 2
Figure 358: 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 Bulk ticket action and Bulk ticket condition
Script types Bulk resource action and Bulk resource condition
Script types Bulk data object action and Bulk data object condition
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 52: 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 359: 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 53: Negative feedback
Figure 360: ConSol CM Web Client - FAILURE message after Search (Result) Action