(SM) Support Tip: How to define checkable queries for search form and check them by default?

Service Manager allows to predefine query clauses which appears in the search form as check boxes.

For example when opening the search from for incidents, there is a list of checkboxes:

Where incidents is

  • Open
  • Closed
  • Assigned to me
  • High priority
  • Total Loss of Service
  • Generated by UCMDB Integration


To define queries yourself for all users:

  1. Open the Object record for the target table, and
  2. Go to the “Search Configuration” tab.
  3. Click “Modify Configuration” button, and
  4. Enter a unique id, the query, and the text how it should appear on the search format in the tables “Defined queries”.


In order to check one of these query checkboxes by default, these are the steps:

  1. In Object record of the target table, on tab “Variables/Global lists” add the variable $L.choices to the list of “Local variables”.
  2. In the Object record also look out for the “Search State” name on “Object info” tab.
  3. Open this State record and identify its “Initialization Process”.
  4. Open this Process record and add the following code on tab “Initial JavaScript”:

   var xml = new XML();


   var x1 = xml.getFirstChildElement();

   while (x1 != null)


     if (x1.getAttributeValue("id") == "<search id>")





     x1 = x1.getNextSiblingElement();


   vars.$L_choices = xml.toXMLString();


<search id> in the code above refers to the unique id of the search definition in the Object record.

Note:    In the table below find Out of the box assignment for Object records, Search States, and Initialization process.

Object record

Search State

Initialization process


imIncident.search (codeless)

im.search (classic)



sd.search (codeless)

sm.search (classic)



change.search (codeless)

cm.search (classic)



change.search (codeless)

cm.search (classic)



In case two Object records have assigned the same Search State Initialization Process, custom JS code is executed in contexts of both Object records. For this reason, warp custom code by a guarding if statement to control the context:

if (system.functions.filename(vars.$L_file) == "cm3r")


     … custom JS code …