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 email to all customers in the result list, or creating a new maintenance ticket for all PCs (resources) in the result list.

Figure 352: ConSol CM Web Client - Search actions for tickets

A search (result) action will be displayed in the Web Client only if

  • the engineer has ACT permissions for all elements of the result set (if any)
  • the condition script (if any) has returned true

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 (navigation group System, navigation item Scripts and Templates)
    • mandatory: a script of type search action for tickets (see following figure)
    • optional: a script of type search condition for tickets
  2. Figure 353: 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

     

    def engineer = engineerService.getCurrent();

    tickets.each { ticket ->;

    ticket.setEngineer(engineer);

    }

    client.showInfoMessage("cmweb.search.assigned").withRefreshContent();

    Code example 49: 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 action script is assigned to the search action. A condition script might also be assigned, but this is optional. You can add the localized term for the Ticket Action using the Localize button. For a detailed explanation of the localization mechanism, please refer to section Localization of Objects in General, Type 1.

    Figure 354: ConSol CM Admin Tool - Tickets, Search Actions: Defining a new ticket search action

Steps to Perform to Implement a Search Action for Resources

  1. Define and write the Admin Tool script
    • mandatory: a script of type search action for resources
    • optional: a script of type search condition for resources
  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

     

    def now = new Date();

    def nextMaintenanceDate;

    use(TimeCategory) {

    nextMaintenanceDate = now + 2.weeks

    }

     

    for(Resource r : resources){

    r.set("HP_Printer_Fields_basic.NextMaintenaceDate", nextMaintenanceDate)

    }

     

    client.showInfoMessage("maintenance.date.updated").withRefreshContent();

    Code example 50: 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 action script is assigned to the search action. A condition script might also be assigned, but this is optional. You can add the localized term for the resource action using the Localize button. For a detailed explanation of the localization mechanism, please refer to section Localization of Objects in General, Type 1.
  4. Figure 355: ConSol CM Admin Tool - Resources, Actions: Defining a resource search 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 356: ConSol CM Admin Tool - Resources, Actions: Assigning a search action to a resource type

  6. Ensure that it works in the Web Client.

    Figure 357: ConSol CM Web Client - Search action on resources, 1

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

Steps to Perform to Implement a Search Action for Customers

  1. Define and write the Admin Tool script
    • mandatory: a script of type search action for customers
    • optional: a script of type search condition for customers, in this example we will work with a condition script
  2. Example action script which creates a ticket for each contact in the result list:

    // deadline is a required field in Service Desk tickets!

    import groovy.time.TimeCategory

     

    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

    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)

    }

     

    client.showInfoMessage("cmweb.search.assigned").withRefreshContent();

    Code example 51: Search action script for customers

    Please make sure that

    • you only use customer fields in the script which are present in the customer data model of the customer group where the Search (Result) Action script will be used! For example: To reference the name of a contact, the exact field name has to be used (customer_name in the example above)! Hence, before implementing a Search (Result) Action script, it is recommended that you check the customer data model for the required fields.
    • the customer group has been assigned to the queue where new tickets should be created.

    Example condition script which causes the search action to only be displayed if the list has more than five entries.

    if (units.size() >= 5){

    return true

    } else {

    return false

    }

    Code example 52: 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 action script is assigned to the search action. A condition script might also be assigned, but this is optional. You can add the localized term for the customer action using the Localize button. For a detailed explanation of the localization mechanism, please refer to section Localization of Objects in General, Type 1.

    Figure 359: ConSol CM Admin Tool - Customers, Actions: Defining a customer search action

  4. Add the condition script.
  5. Figure 360: ConSol CM Admin Tool - Customers, Actions: 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 361: ConSol CM Admin Tool - Customers, Customer Groups: Assigning a search action to a contact object within a customer group

  7. Ensure that it works in the Web Client.

    Figure 362: ConSol CM Web Client - Search action on customers (here: contacts), 1

    Figure 363: ConSol CM Web Client - Search action on customers (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 364: ConSol CM Web Client - Search action on customers (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 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 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.

Display a Message After Executing a Search Action Script

Use the methods of the class OperationResponseBuilder to display feedback messages after a search action script is executed. Two values of OperationType are available:

Example for a positive feedback:

client.showMessage("action.info.executionOK", OperationMessage.Severity.INFO)

Code example 53: 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 365: ConSol CM Web Client - SUCCESS message after search action

Example of a negative feedback:

client.showMessage("action.info.execution.nok", OperationMessage.Severity.WARN)

Code example 54: 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.

Figure 366: ConSol CM Web Client - FAILURE message after search action