How to keep the "Search Results" container collapsed/hidden by default on Record Producer in Service

masaki_ogawa
Tera Expert

Hi everyone,

I am trying to change the default behavior of the Contextual Search / AI Search results on a Record Producer in Employee Center / Service Portal.

 

[Current Behavior] 
When a user types keywords into the "Subject" field, the AI Search automatically triggers, and the "Search Results" container underneath expands immediately, pushing down the other form fields.
Currently, the search results are causing a huge noise and distracting users from entering information smoothly.

 

[Desired Behavior] 
We want to keep the "Search Results" container COLLAPSED or HIDDEN by default when it is triggered by typing.
We want the user to explicitly click a button or an accordion header to expand/show the results, rather than having it expand automatically.

masaki_ogawa_0-1779858528187.png

 

Thank you in advance!

3 REPLIES 3

Tanushree Maiti
Tera Patron

Hi @masaki_ogawa 

 

1. Ensure the system property com.snc.contextual_search.widget.form.open_collapsed_existing_records is set to true.

Refer: KB0813763 Prevent the Related Search Results (contextual Search) to expand on forms 

 

TanushreeMaiti_0-1779860122432.png

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

masaki_ogawa_0-1779860622305.png

Thanks for your comment.

I checked the property "com.snc.contextual_search.widget.form.open_collapsed_existing_records", but it was already set to "true".

Do you have any other solutions or workarounds in mind?

masaki_ogawa
Tera Expert

Thank you for the insights.

To clarify, the "Search Results" section is rendered by the "AI Search Assist" variable  which was automatically added to the Record Producer.

By default, this AI Search Assist widget is designed to automatically expand the search results container as the user types in the Subject field.

Since OOTB properties do not control the initial collapse/expand state of this specific variable's UI container, how can we alter the widget or apply a Client Script / CSS theme to ensure the result list remains collapsed or hidden until the user manually triggers it?

Should we clone the "AI Search Assist" widget and modify its HTML/Client Controller to default to a collapsed state? If so, does anyone have a code snippet to achieve this?