Sample code for the Catalog browse component
reference australia Updated Mar 12, 2026 1 min read we-catalog-browse-samp-code.md
Use this sample code to run an action when the Catalog browse component triggers an event.
Sample code
Update the sample code for your use case before you embed the component on your webpage.
JavaScript
{
'CATALOG_BROWSE#COMPONENT_READY' : (e) => {
// This event is dispatched when a component is ready and usable.
},
'CATALOG_BROWSE#CATALOG_ITEM_SELECTED' : (e) => {
// This event is dispatched when a catalog item is selected.
var {catalog_item_details} = e.detail.payload;
// Logic to construct the URL based on the catalog item details
let redirectURL;
const type = catalog_item_details.type;
if (type === 'catalog_item' || type === 'record_producer') {
redirectURL = '/catalog_form?emb_recordid=' + catalog_item_details.sys_id;
} else if (type === 'content_item') {
const content_type = catalog_item_details.content_type;
if (content_type === 'kb') {
redirectURL = '/article_view?emb_recordid=' + catalog_item_details.kb_article;
} else if (content_type === 'external') {
redirectURL = catalog_item_details.url;
} else if (content_type === 'dynamic') {
const dynamicContentItemDetails = catalog_item_details.dynamicContentItemDetails;
// Check for 'Playbook' dynamic content type
if(dynamicContentItemDetails.dynamicContentType === 'c0e6a71443923110f6669c7385b8f20a')
redirectURL = '/playbook_intake?emb_playbook_title=' + dynamicContentItemDetails.content.title + '&emb_table=' + dynamicContentItemDetails.content.table + '&emb_record_generator=' + dynamicContentItemDetails.content.query + '&emb_playbook_experience=' + dynamicContentItemDetails.content.playbook_experience;
}
}
// Redirect to the respective component page
open(redirectURL, '_self');
},
'CATALOG_BROWSE#COMPONENT_EMPTY' : (e) => {
// This event is dispatched when a component has nothing to display.
},
'CATALOG_BROWSE#COMPONENT_ERROR' : (e) => {
// This event is dispatched when a component encounters an error.
var {errorMessage, errorType} = e.detail.payload;
console.log(errorMessage, errorType);
}Related topics
Configure the Catalog browse component instance
Embed the Catalog browse component on the third-party website
112 lines · 3.7 KB
---
title: Sample code for the Catalog browse component
description: Use this sample code to run an action when the Catalog browse component triggers an event.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/we-catalog-browse-samp-code.html
release: australia
product: Customer Self-service and Omnichannel Engagement
classification: customer-self-service-and-omnichannel-engagement
topic_type: reference
last_updated: "2026-03-12"
reading_time_minutes: 1
breadcrumb: [Catalog browse component, Configure web components, Configure Web Embeddables, Set up self-service, Configure, Customer Service Management]
---
# Sample code for the Catalog browse component
Use this sample code to run an action when the Catalog browse component triggers an event.
## Sample code
Update the sample code for your use case before you embed the component on your webpage.
```
{
'CATALOG_BROWSE#COMPONENT_READY' : (e) => {
// This event is dispatched when a component is ready and usable.
},
'CATALOG_BROWSE#CATALOG_ITEM_SELECTED' : (e) => {
// This event is dispatched when a catalog item is selected.
var {catalog_item_details} = e.detail.payload;
// Logic to construct the URL based on the catalog item details
let redirectURL;
const type = catalog_item_details.type;
if (type === 'catalog_item' || type === 'record_producer') {
redirectURL = '/catalog_form?emb_recordid=' + catalog_item_details.sys_id;
} else if (type === 'content_item') {
const content_type = catalog_item_details.content_type;
if (content_type === 'kb') {
redirectURL = '/article_view?emb_recordid=' + catalog_item_details.kb_article;
} else if (content_type === 'external') {
redirectURL = catalog_item_details.url;
} else if (content_type === 'dynamic') {
const dynamicContentItemDetails = catalog_item_details.dynamicContentItemDetails;
// Check for 'Playbook' dynamic content type
if(dynamicContentItemDetails.dynamicContentType === 'c0e6a71443923110f6669c7385b8f20a')
redirectURL = '/playbook_intake?emb_playbook_title=' + dynamicContentItemDetails.content.title + '&emb_table=' + dynamicContentItemDetails.content.table + '&emb_record_generator=' + dynamicContentItemDetails.content.query + '&emb_playbook_experience=' + dynamicContentItemDetails.content.playbook_experience;
}
}
// Redirect to the respective component page
open(redirectURL, '_self');
},
'CATALOG_BROWSE#COMPONENT_EMPTY' : (e) => {
// This event is dispatched when a component has nothing to display.
},
'CATALOG_BROWSE#COMPONENT_ERROR' : (e) => {
// This event is dispatched when a component encounters an error.
var {errorMessage, errorType} = e.detail.payload;
console.log(errorMessage, errorType);
}
```
**Related topics**
[Configure the Catalog browse component instance](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/we-config-catalog-browse-comp.md)
[Embed the Catalog browse component on the third-party website](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/we-embed-catalog-browse-on-third-party-web.md)
[Component properties for the Catalog browse](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/we-catalog-browse-comp-prop.md)
[Event handlers in the Catalog browse component](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/customer-service-management/we-event-handlers-catalog-browse.md)
| title | Sample code for the Catalog browse component |
| description | Use this sample code to run an action when the Catalog browse component triggers an event. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/australia/customer-service-management/customer-self-service-and-omnichannel-engagement/we-catalog-browse-samp-code.html |
| release | australia |
| product | Customer Self-service and Omnichannel Engagement |
| classification | customer-self-service-and-omnichannel-engagement |
| topic_type | reference |
| last_updated | 2026-03-12 |
| reading_time_minutes | 1 |
| breadcrumb | Catalog browse componentConfigure web componentsConfigure Web EmbeddablesSet up self-serviceConfigureCustomer Service Management |