The CreatorCon Call for Content is officially open! Get started here.

use the global search within a catalog item

Efra Pruneda
Mega Guru

I have been asked to create a catalog item that mirrors what we have in the SN support portal, where the user types a subject and a body describing the issue, then a search is performed looking for existing knowledge articles and once the user reviews the results he/she will have the choice to continue creating a case or not.

 

I am thinking that to implement this, I need to create a catalog item with two variables (subject and body), and somehow invoke the global search, and then display the results. I have no idea if this can be done.

 

Has anyone implemented something like this? I will greatly appreciate some guidance.

 

thank you in advance!

 

Efra

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Efra Pruneda ,

Yes, what you're trying to build is a "deflection-style" catalog item, which is similar to what the ServiceNow Support Portal already does — prompting users to search for solutions before submitting a case. This can absolutely be implemented, though it involves a combination of Service Catalog, Search API, and Client Scripts/UI policies.

1. Create the Catalog Item

  • Create a new Catalog Item under the Service Catalog module.

  • Add two variables:

    • subject (Single Line Text)

    • description or body (Multi Line Text)

These two will serve as the search inputs for knowledge articles

 

2. Trigger Knowledge Article Search

You have two options:

Option A: Use AI Search (Recommended if you have AI Search plugin enabled)

  • Use the Search API (/api/sn_ai_search/search) via a Catalog Client Script.

  • On change of subject/description or via a “Search” button, call this API and pass the variables as search terms.

  • Use a modal or catalog UI message area to display results.

Option B: Use Global Text Search (Fallback)

  • Use a GlideAjax call to a Script Include that performs a GlideRecord query on kb_knowledge table with LIKE on short_description or text fields.

  • Return results and show in HTML variable or modal

 

3. Show Knowledge Results Before Submission

  • Create an HTML variable to display search results dynamically.

  • Use a Client Script to populate this HTML field with results when the search runs.

  • Provide a "Continue" button that reveals the "Submit" button, or disables/enables form submission.

4. Prevent Submission Until Reviewed

To make sure the user reviews knowledge:

  • Hide the native "Submit" button using UI Policy.

  • After search results are displayed, enable/show the Submit button with a checkbox or "Continue" action

5. (Optional) Log User Search Behavior

To track what users are searching, create a logging Script Include to write entries to a custom table for analytics (search keywords, timestamp, whether user submitted, etc.)

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Hi @Efra Pruneda ,

Yes, what you're trying to build is a "deflection-style" catalog item, which is similar to what the ServiceNow Support Portal already does — prompting users to search for solutions before submitting a case. This can absolutely be implemented, though it involves a combination of Service Catalog, Search API, and Client Scripts/UI policies.

1. Create the Catalog Item

  • Create a new Catalog Item under the Service Catalog module.

  • Add two variables:

    • subject (Single Line Text)

    • description or body (Multi Line Text)

These two will serve as the search inputs for knowledge articles

 

2. Trigger Knowledge Article Search

You have two options:

Option A: Use AI Search (Recommended if you have AI Search plugin enabled)

  • Use the Search API (/api/sn_ai_search/search) via a Catalog Client Script.

  • On change of subject/description or via a “Search” button, call this API and pass the variables as search terms.

  • Use a modal or catalog UI message area to display results.

Option B: Use Global Text Search (Fallback)

  • Use a GlideAjax call to a Script Include that performs a GlideRecord query on kb_knowledge table with LIKE on short_description or text fields.

  • Return results and show in HTML variable or modal

 

3. Show Knowledge Results Before Submission

  • Create an HTML variable to display search results dynamically.

  • Use a Client Script to populate this HTML field with results when the search runs.

  • Provide a "Continue" button that reveals the "Submit" button, or disables/enables form submission.

4. Prevent Submission Until Reviewed

To make sure the user reviews knowledge:

  • Hide the native "Submit" button using UI Policy.

  • After search results are displayed, enable/show the Submit button with a checkbox or "Continue" action

5. (Optional) Log User Search Behavior

To track what users are searching, create a logging Script Include to write entries to a custom table for analytics (search keywords, timestamp, whether user submitted, etc.)

Efra Pruneda
Mega Guru

wow! thank you so much! this is exactly what I was looking for!

I really appreciate your time in writing this thorough response.

take care,

Efra