From Bright Pattern Documentation
Jump to: navigation, search
• 5.19

Dynamic Searching

Bright Pattern scenario blocks can search through the ServiceNow instance dictionary to retrieve options for a record. For dependent fields, the previous results can be used in a subsequent search to narrow down returned values. By searching for options for a menu inside the scenario, the IVR will automatically update as categories get updated by ServiceNow admins.


Dynamic Search for Problem Categories

A ServiceNow Search scenario block is used to search through the sys_choice table in the ServiceNow database. This location can be obtained from the sys_dictionary table by searching for the problem table, which returns a list of columns in each record. The category field for a problem is a value from the sys_choice table. The results of all sys_choice entries, where the name is "problem" (i.e., corresponding to the table) and the element is of type category, are stored in the recordset name Categories.


Create a search query


Play Prompt scenario blocks will introduce the category and read the first result found. A Get Next Record scenario block will repeat the category item prompt until no more records are found. Once the end is reached, the user will be prompted by the Play-Listen block to make a selection. Then, a ServiceNow Search scenario block is used with the selection made by the user to get the object of the particular category.


Ss12b.jpg


A ServiceNow Update Object block is used to update the problem record with the category selection. The ProblemID variable was stored by a ServiceNow Create Object scenario block previously. The category field is updated by the value, not the sys_id of the category object.


Ss12c.jpg


This process is repeated for the subcategory search. Again, the sys_choice table is searched where the name is equal to "problem" and the element is a subcategory. An additional search parameter is added where the dependent_value is restricted to the label of the previously located category object. In this manner, the subcategory results returned will be ones only found in a problem record where the category was the one previously selected.


Ss12d.jpg


Dynamic Search for Self-Service Catalog

Dynamic search is needed for catalog item retrieval in the Self-Service catalog. Catalogs are formed in a tree-like structure with categories and subcategories as the branches. Items can be at any level from root to leaf. To find an item in a given catalog, do the following:

  • List the items at the current level.
  • List the category or subcategory at the current level.
  • If the selection is an item, exit the search.
  • If the selection is a category, repeat the search.


Two search strings are used: one for the categories and one for the items. The initial values of both will be set to the catalog name and the empty parent. This will search the root of the catalog: ="catalog="+"$(Catalog.title)"+"^parentISEMPTY" where $(Catalog) was the previously retrieved catalog object.


1. List the Items at the Current Level

A ServiceNow Search scenario block is used to find the items specified by the itemSearch string in the sc_cat_item table.


List the items


2. List the Category or Subcategory at the Current Level

A ServiceNow Search scenario block is used to find the categories specified by the catSearch string in the sc_category table. With a list of items and categories at the current level, a Play-Listen scenario block is used to read the options to the user. This selection is used to determine the next step.


Ss14b.jpg


3. Exit the Search for Items

A ServiceNow Search block is used to retrieve the item object from the sc_cat_item table, where the name is equal to the selection provided by the user.


Ss14c.jpg


4. Repeat the Search for Categories

If the selection fails to be found in the sc_cat_item table, then the search is repeated in the sc_category table. If a match is found, the process repeats at the new level. If no category is found, the user is asked to repeat their selection since it was invalid.

The catalog and items search strings are updated to reflect the category as the new parent in the subsequent search by setting them to ="catalog="+"$(Catalog.title)"+"^parent="+"$(Category.title)". Once the dynamic search locates the user item, the scenario continues to create the catalog request as in this scenario.


Ss14d.jpg
< Previous | Next >