
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 09:23 AM
Hi All,
Widget -- > myHR KB Article Page
Server Code snippet
t.text = new global.KBViewModel().getArticleContentBySysId(articleGR.getUniqueValue());
Script Include : KBViewModel --- > overriding the KBViewModelSNC
getArticleContentBySysId : function(articleSysId){ // OOB CODE
var gr = new GlideRecord("kb_knowledge");
var userId = gs.getUserID();
if(!articleSysId || !gr.get(articleSysId) || !gr.canRead())
return '';
this.knowledgeRecord = gr;
if(!this.tableName)
this.tableName = gr.sys_class_name + '';
if(!this.articleTemplateName)
this.articleTemplateName = this._knowledgeHelper.getArticleTemplateName(gr.sys_class_name) || '';
gs.info('article template name is:'+this.articleTemplateName);
gs.info('article content is:'+this.getArticleContent());
return this.getArticleContent();
},
However the article content is returning as empty when the article is created on HR knowledge (u_kb_template_hr_knowledge) table and when knowledge blocks are applied to it.
But when the article is created on kb_knowledge table and when I apply the blocks to it, it is rendering correctly the KB blocks correctly.
Can anyone please help me what the issue is ?
Help is appreciated.
Regards,
Dheeraaj
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 08:38 AM
Hi Ali,
I have figured out a way to do implement this and now its working super good.
For anyone trying to implement the similar functionality, for the kb blocks to get rendered in the service portal for a different template other than the standard, the article along with the block should get populated in the KB Knowledge to Block History table.
Regards,
Dheeraaj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 10:13 AM
Also one more question that I have is , I am trying to find why this.getArticleContent() in the code above is returning the value when the article is on Knowledge table and not returning the value when the article is on the HR knowledge table (u_kb_template_hr_knowledge)
Regards,
Dheeraaj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2019 10:22 AM
The actual logic for fetching the blocks are scripted in the KBBlockSNC script include. If you check this script, it is accessing an SNC.KnowledgeBlockSubstitution() where the rendering happens.
SNC means platform code and we do not have access into it. Maybe the function validates to check if the parent record is from kb_knowledge and only then it renders. I suggest you keep using kb_knowledge for rending knowledge blocks
/**
* Returns the article text content, with blocks substituted if blocks are enabled.
*/
getArticleContent: function(knowledgeGR,userId,blocksArray) {
var previewAsUser = gs.nil(userId)!= true ? userId : gs.getUserID();
if(!gs.nil(blocksArray))
return new SNC.KnowledgeBlockSubstitution().substituteBlockOnDate(knowledgeGR.sys_id, knowledgeGR.text, previewAsUser,blocksArray);
else if(this.hasBlocks(knowledgeGR))
return new SNC.KnowledgeBlockSubstitution().substituteBlock(knowledgeGR.sys_id, knowledgeGR.text, previewAsUser);
else
return knowledgeGR.text + '';
},

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2019 08:38 AM
Hi Ali,
I have figured out a way to do implement this and now its working super good.
For anyone trying to implement the similar functionality, for the kb blocks to get rendered in the service portal for a different template other than the standard, the article along with the block should get populated in the KB Knowledge to Block History table.
Regards,
Dheeraaj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2020 08:23 AM
Please let me know how u implemented this. i am blocked on the same issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2020 04:08 PM
this is not working for me for users with no role or group.