Micro Focus Expert
Micro Focus Expert
54 views

(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();

   xml.setContent(vars.$L_choices);

   var x1 = xml.getFirstChildElement();

   while (x1 != null)

   {

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

     {

         x1.setValue("true");

         break;

     }

     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

probsummary

imIncident.search (codeless)

im.search (classic)

cc.search.init

incidents

sd.search (codeless)

sm.search (classic)

sd.search.init

cm3r

change.search (codeless)

cm.search (classic)

cm.search.init

cm3t

change.search (codeless)

cm.search (classic)

cm.search.init

 

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 …

}

Labels (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.