use the global search within a catalog item

Efra Pruneda
Giga 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

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

4 REPLIES 4

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
Giga 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

cajimenezps
Tera Contributor

Hi @Efra Pruneda, I am encountering a similar situation here and it seems like the suggestion was all custom. I was wondering, is there an OOTB solution you explored for the mentioned use case?

 

Thanks!

Hello, thank you for reaching out! We are using the Yokohama release, and as far as I know, it does not have OOB functionality to offer the choice to create a case after the user performs a knowledge search. So yes, this is custom code.