Exemple de code pour le composant d’affichage d’article de la base de connaissances

  • Rversion finale: Australia
  • Mis à jour 12 mars 2026
  • 1 minute de lecture
  • Un exemple de code est fourni pour définir une action lorsqu’un événement est déclenché. Mettez à jour l’exemple de code pour votre cas d’utilisation avant d’intégrer le composant sur votre page Web.

    Exemple de code

    { 
    
    '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); 
    
    }