Add contextual search for Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team,
I have to add contextual search(context searching from knowledge and catalog item) for catalog item variable. Yes, we can easily do it for record producer but how can we set up for catalog item variables?
I tried creating variable of custom variable and using "cxs_rp_search" macro and "Contextual Search - Inline Results" Widget. But nothing is being displayed. (Screenshot attached)
Please guide!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The cxs_rp_search macro approach works for Record Producers because they render in the platform UI (backend form view), where UI Macros execute natively. Service Catalog items, however, are typically consumed through Service Portal or Employee Center, which use an entirely different rendering engine (AngularJS widgets). The macro simply never gets invoked in that context — that's why you see nothing.
Here's how to approach it depending on your rendering context:
If your catalog item is consumed via Service Portal / Employee Center:
The widget reference ("Contextual Search - Inline Results") on the variable definition is the right idea, but it requires the portal page/widget framework to actually instantiate it. You need to ensure a few things:
-
CXS plugins are active — make sure both
com.snc.contextual_searchandcom.snc.contextual_search.portal(or the dynamic variant) are activated. The portal plugin is what enables CXS rendering inside Service Portal. -
Search Context configuration — go to Contextual Search > Search Contexts and verify you have a search context configured that targets Knowledge (
kb_knowledge) and/or Catalog Items (sc_cat_item). The search context needs to be tied to the correct source and have search rules defined. -
Use the OOB approach instead of a custom variable — rather than manually wiring a Custom type variable with the macro, ServiceNow's intended pattern for catalog items in the portal is to enable CXS at the catalog item or variable set level through the Contextual Search configuration records. Check under Contextual Search > Configurations and create a config that maps to your catalog item or the specific variable where you want inline results to appear.
-
Variable attributes — on your variable (typically a Single Line Text or Reference type, not Custom), add the variable attribute
cxs_search_context=<your_search_context_sys_id_or_name>. This tells the portal widget framework to attach the CXS behavior to that variable.
If you need it on the platform UI (backend) for the catalog item:
The macro-based approach (cxs_rp_search) can work, but only when the catalog item is being filled out via the platform UI (not the portal). Make sure you're testing in the backend form view (/nav_to.do?uri=com.glideapp.servicecatalog_cat_item_view.do?...) rather than through the portal.
Recommended approach (portal):
The cleanest path is to not use a Custom variable type at all. Instead, use a standard Single Line Text variable and attach the CXS behavior through variable attributes pointing to your search context. The portal CXS framework picks up that attribute and renders the inline search results automatically beneath the field.
If you want, I can walk you through the exact Search Context and Configuration setup steps, or help you troubleshoot why the widget isn't rendering if you've already done the configuration piece?
