{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":47516,"path":"servicenow-platform/knowledge-management/KBBlockAPI.md","title":"KBBlock - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# KBBlock - Global\n\nThe `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.\n\n**Parent Topic:**[Integrating a custom search or knowledge article viewer with knowledge blocks](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/servicenow-platform/knowledge-management/integrating-with-custom-search-or-knowledge-article-viewer.md)\n\n## KBBlock - KBBlock\\(\\)\n\nInstantiates a KBBlock object in a global application.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n## KBBlock - getArticleContent\\(GlideRecord knowledgeRecord\\)\n\nGets knowledge articles with relevant knowledge block content that a user has access to read.\n\nIf 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.\n\n|Name|Type|Description|\n|----|----|-----------|\n|knowledgeRecord|GlideRecord|GlideRecord of the knowledge article to display.|\n\n|Type|Description|\n|----|-----------|\n|String|Knowledge article with relevant knowledge block content that a user has access to read.|\n\n### Integrating a custom knowledge article viewer with knowledge blocks\n\n```\n\n// This function returns the article text with expanded block content.\nfunction getArticleText(kbSysId) {\n  var knowledgeRecord = new GlideRecord('kb_knowledge');\n  var kbText='';\n  if(knowledgeRecord.get(kbSysId)) {\n    if(new GlidePluginManager().isActive('com.snc.knowledge_blocks')) {\n      kbText = new KBBlock();\n      kbText.getArticleContent(knowledgeRecord);\n    }\n    else\n      kbText = knowledgeRecord.getValue('text');\n    }\n  return kbText;\n}\n\n// This is an example of how to call the function defined above.\nvar kbText = getArticleText('01a1ca5b6710130038876c3b5685efd3');\n```\n\n"}}