(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
- Assigned to me
- High priority
- Total Loss of Service
- Generated by UCMDB Integration
To define queries yourself for all users:
- Open the Object record for the target table, and
- Go to the “Search Configuration” tab.
- Click “Modify Configuration” button, and
- 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:
- In Object record of the target table, on tab “Variables/Global lists” add the variable $L.choices to the list of “Local variables”.
- In the Object record also look out for the “Search State” name on “Object info” tab.
- Open this State record and identify its “Initialization Process”.
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.
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 …