- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2016 07:28 AM
Hi all,
I found out that in the new Service Portal attachments in knowledge articles just don't get displayed (I have Display Attachments to true in the article). They do show up in the Knowledge homepage. I am not sure if I am doing something wrong, missing an option or this is the intended functionality but any answer will be appreciated. If this is the intended functionality of the new portal - why and do I have to rewrite the widget to make it work?
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2016 01:10 PM
Hi Miryana,
There was currently only a ticket attachment widget in Service Portal. I've attached a completed widget for you to use (xml record to import). As well as placed the code below for others to examine. The widget will look to see if there are attachments associated with the knowledge base article and if the "display attachments" checkbox has been checked. Please let me know if you have any questions.
Body HTML Template
<div class="panel panel-{{options.color}} b kbattach" ng-show="data.theArticle">
<div class="panel-heading"> <h4 class="panel-title" ng-bind="::options.title">
<fa ng-if="::options.glyph.length" name="::{{options.glyph}}" class="m-r-sm" /></h4>
</div>
<div class="panel-body">
<div ng-repeat="list in data.attachments" style="margin-bottom: 1em;">
<a ng-href="/sys_attachment.do?sys_id={{list.sys_id}}">{{list.file_name}}</a>
</div>
<div ng-show="(data.attachments).length < 1" style="margin-bottom: 1em;">
There are currently zero attachments
</div>
</div>
</div>
Server Script
data.theArticle = false;
var theSysID = $sp.getParameter('sys_id');
var gr = new GlideRecord("kb_knowledge");
gr.addQuery('sys_id', theSysID);
gr.addQuery('display_attachments', true);
gr.query();
while (gr.next()) {
var display_attachments = gr.display_attachments;
}
data.theArticle = display_attachments;
var attachments = [];
var attachdata = new GlideRecord("sys_attachment");
attachdata.addQuery('table_name', 'kb_knowledge');
attachdata.addQuery('table_sys_id', theSysID);
attachdata.query();
while (attachdata.next()) {
var attach = {};
attach.file_name = attachdata.file_name.getDisplayValue();
attach.sys_id = attachdata.getValue('sys_id');
attachments.push(attach);
}
data.attachments = attachments;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2016 01:10 PM
Hi Miryana,
There was currently only a ticket attachment widget in Service Portal. I've attached a completed widget for you to use (xml record to import). As well as placed the code below for others to examine. The widget will look to see if there are attachments associated with the knowledge base article and if the "display attachments" checkbox has been checked. Please let me know if you have any questions.
Body HTML Template
<div class="panel panel-{{options.color}} b kbattach" ng-show="data.theArticle">
<div class="panel-heading"> <h4 class="panel-title" ng-bind="::options.title">
<fa ng-if="::options.glyph.length" name="::{{options.glyph}}" class="m-r-sm" /></h4>
</div>
<div class="panel-body">
<div ng-repeat="list in data.attachments" style="margin-bottom: 1em;">
<a ng-href="/sys_attachment.do?sys_id={{list.sys_id}}">{{list.file_name}}</a>
</div>
<div ng-show="(data.attachments).length < 1" style="margin-bottom: 1em;">
There are currently zero attachments
</div>
</div>
</div>
Server Script
data.theArticle = false;
var theSysID = $sp.getParameter('sys_id');
var gr = new GlideRecord("kb_knowledge");
gr.addQuery('sys_id', theSysID);
gr.addQuery('display_attachments', true);
gr.query();
while (gr.next()) {
var display_attachments = gr.display_attachments;
}
data.theArticle = display_attachments;
var attachments = [];
var attachdata = new GlideRecord("sys_attachment");
attachdata.addQuery('table_name', 'kb_knowledge');
attachdata.addQuery('table_sys_id', theSysID);
attachdata.query();
while (attachdata.next()) {
var attach = {};
attach.file_name = attachdata.file_name.getDisplayValue();
attach.sys_id = attachdata.getValue('sys_id');
attachments.push(attach);
}
data.attachments = attachments;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2016 02:21 AM
Awesome Brett!
I managed to write something similar. Also alternatively link attachments can be used as part of the text.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 08:27 PM
Hi Brett, I downloaded the version from Share and added the widget onto the kb article page and it all seemed OK. However, after clicking any attachment link, 'sys_attachment.do?' appears in the middle of the URL even if you try to use the breadcrumbs above the kb article to go to 'Home' or 'Knowledge Base'.
As per the screenshot, check the URL at the bottom. Hope you or the community can assist.
Regards, Dale.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2016 01:39 AM
Hello Dale,
this can be easily fixed by opening the attachment on a new blank page.
Modify line 7 to:
<a target="_blank" ng-href="/sys_attachment.do?sys_id={{list.sys_id}}">{{list.file_name}}</a>
František