Control Visibility of attachments of in KB Articles
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I want to show only pdfs attached in the article body not the jpg files in the portal of the knowledge article.
If I make display attachments false I am missing pdfs along with jpgs.
suggest better approach.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You can create a user criteria . Add required user/role/group/company & add script using your logic.
Logic should be
you need to check current KB article's attachment in sys_attachment table and its Content Type .
If Content type is pdf . it will not be accessible to user/group/role
else
it would be visible .
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Below is the method that will query the attachments. You can override this method in the KBViewModel script include to fit your requirements.
//global.KBViewModelSNC
getAttachments: function () {
var tableUtils = new TableUtils(this.tableName);
var tn = tableUtils.getAllExtensions();
var att = new GlideRecord("sys_attachment");
att.addQuery("table_name", tn);
att.addQuery("table_sys_id", this.knowledgeRecord.sys_id);
att.orderByDesc("sys_created_on");
att.setCategory('homepage');
att.query();
var attachments = [];
while (att.next() && att.canRead())
attachments.push({sys_id: att.sys_id + "", file_name: att.file_name + "", size: att.getDisplayValue("size_bytes") + "", state: att.getValue("state") + ""});
return attachments;
},
