Sample code to handle the Case view component
reference brazil Updated Sep 10, 2026 1 min read we-case-view-sample-code.md
Use this sample code to run an action when the Case view component triggers an event.
Sample code
Update the sample code for your use case before you embed the component on your webpage.
JavaScript
{
'SN_EMBEDX_CASE_VIEW#COMPONENT_READY' : (e) => {
// This event is dispatched when a component is ready and usable.
},
'SN_EMBEDX_CASE_VIEW#COMPONENT_ERROR' : (e) => {
// This event is dispatched when a property validation or internal error occurs.
var {errorMessage, errorType} = e.detail.payload;
console.log(errorMessage, errorType);
},
'SN_EMBEDX_CASE_VIEW#CASE_COMMENT_ADDED' : (e) => {
// This event is dispatched when a comment is added in the activity stream. } };
setEvents(snEmbedxCaseView, eventHandlers);</script>Related topics
Configure the Case view component instance
Embed the Case view component instance on the third-party website
62 lines · 2.4 KB
---
title: Sample code to handle the Case view component
description: Use this sample code to run an action when the Case view component triggers an event.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/customer-service-management/customer-self-service-and-omnichannel-engagement/we-case-view-sample-code.html
release: brazil
product: Customer Self-service and Omnichannel Engagement
classification: customer-self-service-and-omnichannel-engagement
topic_type: reference
last_updated: "2026-09-10"
reading_time_minutes: 1
breadcrumb: [Case view component, Configure web components, Configure Web Embeddables, Set up self-service, Configure, Customer Service Management]
---
# Sample code to handle the Case view component
Use this sample code to run an action when the Case view component triggers an event.
## Sample code
Update the sample code for your use case before you embed the component on your webpage.
```
{
'SN_EMBEDX_CASE_VIEW#COMPONENT_READY' : (e) => {
// This event is dispatched when a component is ready and usable.
},
'SN_EMBEDX_CASE_VIEW#COMPONENT_ERROR' : (e) => {
// This event is dispatched when a property validation or internal error occurs.
var {errorMessage, errorType} = e.detail.payload;
console.log(errorMessage, errorType);
},
'SN_EMBEDX_CASE_VIEW#CASE_COMMENT_ADDED' : (e) => {
// This event is dispatched when a comment is added in the activity stream. }
};
setEvents(snEmbedxCaseView, eventHandlers);
</script>
```
**Related topics**
[Configure the Case view component instance](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/customer-service-management/customer-self-service-and-omnichannel-engagement/configure-case-view-component-on-instance.md)
[Embed the Case view component instance on the third-party website](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/customer-service-management/customer-self-service-and-omnichannel-engagement/embed-case-view-comp-on-third-party-website.md)
[Component properties for the Case view](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/customer-service-management/component-properties-for-case-view-comp.md)
[Event handler in the enhanced Case view component](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/customer-service-management/we-case-view-event-handler.md)
| title | Sample code to handle the Case view component |
| description | Use this sample code to run an action when the Case view component triggers an event. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/customer-service-management/customer-self-service-and-omnichannel-engagement/we-case-view-sample-code.html |
| release | brazil |
| product | Customer Self-service and Omnichannel Engagement |
| classification | customer-self-service-and-omnichannel-engagement |
| topic_type | reference |
| last_updated | 2026-09-10 |
| reading_time_minutes | 1 |
| breadcrumb | Case view componentConfigure web componentsConfigure Web EmbeddablesSet up self-serviceConfigureCustomer Service Management |