Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Tom Cullen
ServiceNow Employee
ServiceNow Employee

How many times a day do you "google"? It's where we go for information.   I'm not exactly sure how many times I use the search engine, but if you're interested in what everyone else is doing .. check out this link (http://www.internetlivestats.com/google-search-statistics/).   Pretty wild.

I thought about this the other day when I needed to search for some text in a custom application I was building.   I   considered using a list search with a   "contains" clause, but in this case I needed data from two different tables (Site and Event).   I ended up writing a GlideRecord query to get the data I needed.   Then I realized the users of this application would not have access to write these native queries, and even if they did ... what kind of a user experience is that.

I've been meaning to dig into Zing Text Search but didn't have a real need to until now.   The rest of this blog contains the steps I took to add value for this particular application.

NOTE:   The information I mention is a subset of the full power of the Zing Text Search.   For more information here is the documentation reference (https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/search-administratio...).

The Application

I'm part of a team working on a city guide application.   You   know, the application you'd use if you went to a new city that helps you find local sites and events.   Turns out there's more to building this type of application than just a slick mobile interface although we do have this as well (done via portal by the way).   Behind the scenes, there is a site and event discovery engine.   As this application discovers activities it creates corresponding records in the guide application.   A workflow kicks off and scans the content for application compliance and auto-approves the site/event or routes it to the site administrator for a manual approval.   There is also a customer service group that monitors and maintains the quality and integrity of this information.   We are focused on making it easy for these groups to quickly get the information they need.

The Issue

The bulk of information for this application is stored in text fields.   Site and event names are important, but site and event description fields are where the information lives. A list lookup using a "name contains" or a "description contains" filter will not cut it.

Screen Shot 2017-06-29 at 8.02.49 AM.pngScreen Shot 2017-06-29 at 8.02.14 AM.png

Writing a GlideRecord query is not an option either.   Note even though these two queries returned the same records, they are in a different order. An "order by" or sort won't help either because we need to somehow understand what's in the name and description fields. How can we be more like google?   How can the application respond with relevant information in a logical order?

The Solution

Apply Zing text search to our tables of course! Here's how to do it:

  1. Enable text indexing for a table
    1. Navigate to System Definition > Dictionary
    2. Open the Table   (column name is empty)
    3. Select the Text Index checkbox
    4. UPDATE
    5. Click Generate Text Index (related list)
  2. Set the relative weight of a field  
    1. Open the System Dictionary entry for the field
    2. In the Attributes section enter "ts_weight=<weight>"   where the value is the relative weight of the field.
      1. Zing awards a record more points if the field in which it appears is weighted.   Zing applies a multiplier to frequency points based on the value of the   ts_weight attribute for the field.
      2. By default, each field has a weight of 1. A field with a weight of 50 (ts_weight=50) would add 50 points each time a search term appeared in the field.   The maximum possible weight value is 255.   For more information see Document Scoring: https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/search-administratio...
      3. Screen Shot 2017-06-29 at 8.15.12 AM.png
  3. Add a search group
    1. Navigate to System Definition > Search Groups
    2. Click NEW
    3. Complete the form
      1. Name
      2. Roles (optional) ... this is what I used to allow only the "guide admin" role
      3. User group (optional)
      4. Active
      5. Order
    4. Right click the form header and select SAVE
    5. In the Text Search Tables related list click NEW
    6. Complete the form
    7. click SUBMIT
    8. Add any other text search tables to the include in the search group
      1. In my example I looped back to step 5 and added the Site table
      2. Screen Shot 2017-06-29 at 10.52.37 AM.png
  4. ** VERY IMPORTANT ** Register your scoped role(s) with Global Text Search
    1. Navigate to System Properties > Global Text Search
    2. Find the property: "List of roles(comma-separated) that can use the Global Text Search capability"
    3. Add your scoped role(s) to this list

Screen Shot 2017-06-29 at 10.39.50 AM.png

The Result

When calls come in or research has to be done, the guide administrators can use ServiceNow global search to retrieve all relevant records quickly and in order.   If necessary the weights of any field can be adjusted to return expected results.

Screen Shot 2017-06-29 at 8.03.40 AM.png

Pretty straight forward.   Every custom application may not need to use Zing Text Search, but it's nice to know you've got it when it counts!

2 Comments