Action Framework - Search Actions

Introduction to Search Actions

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 280: 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

Configuring Search Actions Using the Admin Tool

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.

Steps to Perform to Implement a Search Action for Tickets

  1. Define and write the Admin Tool script
  2. Figure 281: 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 44: 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.

  3. Define the Search Action in the navigation item Search Actions, navigation group Tickets. During this step, the execution script is assigned to the search action. A condition script might also be assigned, but this is optional.

    Figure 282: ConSol CM Admin Tool - Defining a new ticket search action

Steps to Perform to Implement a Search Action for Resources

  1. Define and write the Admin Tool script
  2. 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 45: 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.

  3. Define the Search Action in the navigation item Actions, navigation group Resources. During this step, the execution script is assigned to the search action. A condition script might also be assigned, but this is optional.
  4. Figure 283: ConSol CM Admin Tool - Defining a Resource Search (Result) Action

  5. Assign the action to one or more resource type(s), navigation group Resources, navigation item Data Models, tab Search Actions for each resource type.

    Figure 284: ConSol CM Admin Tool - Assigning a Search Action to a Resource Type

  6. Ensure that it works in the Web Client.

    Figure 285: ConSol CM Web Client - Search (Result) Action on resources, 1

    Figure 286: ConSol CM Web Client - Search (Result) Action on resources, 2

Steps to Perform to Implement a Search Action for Data Objects (= Units = Customers)

  1. Define and write the Admin Tool script
  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 46: 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 47: 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.

  3. Define the Search Action in the navigation item Actions, navigation group Customers. During this step, the execution script is assigned to the search action. A condition script might also be assigned, but this is optional.

    Figure 287: ConSol CM Admin Tool - Defining a Unit Search (Result) Action

  4. Add the condition script.
  5. Figure 288: ConSol CM Admin Tool - Defining a Search Script Condition

  6. Assign the action to one or more customer groups, navigation group Customers, navigation item Customer Groups, tab Search Actions for each customer group. Assign the action(s) to the contacts (Contact Search Actions) and/or the company/companies (Company Search Actions) of this customer group.
    Note that the action and condition scripts are listed together in one table.

    Figure 289: ConSol CM Admin Tool - Assigning a Search Action to a contact object within a customer group

  7. Ensure that it works in the Web Client.

    Figure 290: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 1

    Figure 291: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 2

    Figure 292: ConSol CM Web Client - Search (Result) Action on units (here: contacts), 3

Tips and Tricks for Search Action Admin Tool Scripts

Objects Implicitly Available for Search Action Admin Tool Scripts

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 Result Set in Search Action Admin Tool Scripts

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.

The Return Code in Search Action Admin Tool Scripts

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 48: 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 293: 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.

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

Code example 49: Negative feedback

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