---
sourceDocument: Australia Customer Service Management
sourceDocumentLink: https://www.servicenow.com/docs/r/customer-service-management

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia Customer Service Management

ft:clusterId :

    - csm

bundleId :

    - csm

workflow :

    - Customer and Industry


---

# Sample code for the Knowledge article view component

# Sample code for the Knowledge article view component {#ariaid-title1}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Sample code is provided to define an action when an event is triggered. Update the sample code for your use case before embedding the component on your webpage.

## Sample code {#we-know-article-view-sample-code__section_j4x_gyn_c2c}

    { 

    'SN_EMBEDX_KNOWLEDGE_ARTICLE_VIEW#COMPONENT_READY' : (e) => { 

    // This event is dispatched when a component is ready and usable. 

    }, 

    'SN_EMBEDX_KNOWLEDGE_ARTICLE_VIEW#LINK_CLICKED' : (e) => { 

    // This event is dispatched when a record link has been clicked inside article body 

    var {table, sys_id} = e.detail.payload; 

    console.log(table, sys_id); 

    }, 

    'SN_EMBEDX_KNOWLEDGE_ARTICLE_VIEW#LANGUAGE_DROPDOWN_CLICKED' : (e) => { 

    // This event is dispatched when language dropdown selection is clicked 

    var {articleID} = e.detail.payload; 

     

    // Set properties for the knowledge article view 

    setProperties(snEmbedxKbArticleView, {recordId: articleID}); 

    }, 

    'SN_EMBEDX_KNOWLEDGE_ARTICLE_VIEW#NOTIFICATION_LINK_CLICKED' : (e) => { 

    // This event is dispatched when link present on notification has been clicked 

    var {table, sys_id} = e.detail.payload; 

     

    if(table == 'kb_knowledge') { 

    // Set properties for the knowledge article view 

    setProperties(snEmbedxKbArticleView, {recordId: sys_id}); 

    } 

    }, 

    'SN_EMBEDX_KNOWLEDGE_ARTICLE_VIEW#RATING_CLICKED' : (e) => { 

    // This event is dispatched when rating is provided for the article 

    var {rating} = e.detail.payload; 

    console.log(rating); 

    }, 

    'SN_EMBEDX_KNOWLEDGE_ARTICLE_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); 

    }

**Related tasks**   

* [Configure the Knowledge article view component instance](https://www.servicenow.com/docs/e2QetGo4MldzeS5ZAQIoqg "Configure the Knowledge article view component instance so that your users can embed it on their website to access knowledge articles from their website directly.")
* [Embed the Knowledge article view component instance on the third-party website](https://www.servicenow.com/docs/zVp_NQ7JyqTBEcAi2XDkbw "Embed the global code and component code of the Knowledge article view component instance that you configured so that you can enable your customers to start using the Knowledge article view component instance on your third-party website.")  
**Related reference**   

* [Component properties for the Knowledge article view](https://www.servicenow.com/docs/Kd2dFrn7Tuc7yhR5tgFRbQ "Component property enables you to configure the behavior of the Knowledge article view component instance on the third-party website.")
* [Event handler in the Knowledge article view component](https://www.servicenow.com/docs/_rDG0xcnYEIEVscBT9uEEQ "A component triggers an event when a certain condition is met or on user interaction. The event can be used to execute an action through a code on a third-party webpage.")

