KBBlock - Global

  • Rversion finale: Australia
  • Mis à jour 12 mars 2026
  • 1 minute de lecture
  • The KBBlock API is included with knowledge blocks [com.snc.knowledge_blocks] as a script include. It provides methods to use with the knowledge blocks feature, such as integration with a custom knowledge article viewer.

    KBBlock - KBBlock()

    Instantiates a KBBlock object in a global application.

    Tableau 1. Parameters
    Name Type Description
    None

    KBBlock - getArticleContent(GlideRecord knowledgeRecord)

    Gets knowledge articles with relevant knowledge block content that a user has access to read.

    If you have activated the knowledge blocks feature and are using a custom knowledge article viewer with your application, your viewer may not display articles that expand the relevant block content. To expand block content that a user has access to read, you must call the getArticleContent() method inside your custom viewer.

    Tableau 2. Parameters
    Name Type Description
    knowledgeRecord GlideRecord GlideRecord of the knowledge article to display.
    Tableau 3. Returns
    Type Description
    String Knowledge article with relevant knowledge block content that a user has access to read.

    Integrating a custom knowledge article viewer with knowledge blocks

    
    // This function returns the article text with expanded block content.
    function getArticleText(kbSysId) {
      var knowledgeRecord = new GlideRecord('kb_knowledge');
      var kbText='';
      if(knowledgeRecord.get(kbSysId)) {
        if(new GlidePluginManager().isActive('com.snc.knowledge_blocks')) {
          kbText = new KBBlock();
          kbText.getArticleContent(knowledgeRecord);
        }
        else
          kbText = knowledgeRecord.getValue('text');
        }
      return kbText;
    }
    
    // This is an example of how to call the function defined above.
    var kbText = getArticleText('01a1ca5b6710130038876c3b5685efd3');