- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 09:26 AM
I have a very simple widget and I can't get it to display properly. I know I'm missing something basic, but I don't know what it is.
HTML
<div>
{{::data.text}}
</div>
Server
(function() {
var tocArt = new GlideRecord('kb_knowledge');
var returnValue = tocArt.get('37ff03a187815110c0682f8f8bbb35d2');
data.text = tocArt.text;
})();
That's it. I just want to display the text of an article. What am I missing?
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 09:48 AM
Hey Garrett,
Trying changing your widget code to the below:
Server Script
(function() {
var tocArt = new GlideRecord('kb_knowledge');
if (tocArt.get('37ff03a187815110c0682f8f8bbb35d2')) {
data.text = new global.KBViewModel().getArticleContentBySysId(tocArt.getUniqueValue());
}
})();
CSS
td {
padding: .5em;
}
.knowledge-wiki-text {
dl {
margin-top: .2em;
margin-bottom: .5em;
}
dd {
line-height: 1.5em;
margin-left: 2em;
margin-bottom: .1em;
}
}
HTML
<div>
<div ng-if="!data.direct" class="kb_article" ng-class="{'knowledge-wiki-text' : data.articleType == 'wiki'}" ng-bind-html="::data.text" style="overflow-x:auto;"></div>
</div>
As an FYI - there is already a widget that is used OOTB for displaying the details of a KB article (I borrowed my code from there), take a look at the KB Article Page widget on your instance to understand how they are displayed (and if you need to borrow any other code for your means). You may find that you can just use this widget instead of having to create a new one yourself.
Have attached my dummy widget with the above code as an XML.
Thanks,
Ethan
Please mark this answer as correct or helpful if it solved your problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 09:47 AM
Can you try below as server side logic
(function() {
var tocArt = new GlideRecord('kb_knowledge');
tocArt.addQuery('sys_id','37ff03a187815110c0682f8f8bbb35d2');
tocArt.query();
if(tocArt.next())
{
data.text = tocArt.text;
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 09:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 09:48 AM
Hey Garrett,
Trying changing your widget code to the below:
Server Script
(function() {
var tocArt = new GlideRecord('kb_knowledge');
if (tocArt.get('37ff03a187815110c0682f8f8bbb35d2')) {
data.text = new global.KBViewModel().getArticleContentBySysId(tocArt.getUniqueValue());
}
})();
CSS
td {
padding: .5em;
}
.knowledge-wiki-text {
dl {
margin-top: .2em;
margin-bottom: .5em;
}
dd {
line-height: 1.5em;
margin-left: 2em;
margin-bottom: .1em;
}
}
HTML
<div>
<div ng-if="!data.direct" class="kb_article" ng-class="{'knowledge-wiki-text' : data.articleType == 'wiki'}" ng-bind-html="::data.text" style="overflow-x:auto;"></div>
</div>
As an FYI - there is already a widget that is used OOTB for displaying the details of a KB article (I borrowed my code from there), take a look at the KB Article Page widget on your instance to understand how they are displayed (and if you need to borrow any other code for your means). You may find that you can just use this widget instead of having to create a new one yourself.
Have attached my dummy widget with the above code as an XML.
Thanks,
Ethan
Please mark this answer as correct or helpful if it solved your problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2022 09:51 AM
That worked. I'll dive into other widgets from here on out. I think using a standard call didn't work because the return value was too long. Good to know and thank you!