Opening a knowledge article that contains an attachment does not download directly in Service Portal


Description

If you have a knowledge article which only has an attachment, opening the knowledge article from Service Portal does not automatically download the attached file.

Steps to Reproduce

  1. Create a knowledge article.
  2. Add an attachment to the article.
  3. Ensure both "Display Link" and "Display Attachments" are checked.
    2. Publish the article.
    3. Search for the knowledge article on service portal.
    4. Click on the link of the knowledge article from the search results. The download of the attachment does not start, the article itself opens instead.

Workaround

This problem has been fixed. If you are able to upgrade, review the Fixed In section to determine the latest version with a permanent fix your instance can be upgraded to.

The pre-Orlando workaround was the following:

  1. Make a clone of the out of the box KB Category Page widget

  2. In the HTML template section change the following line of code from:
    <a ng-href="?id=kb_article&sys_id={{::kb_article.sys_id}}">{{::kb_article.title}}</a>
    to:
    <a ng-href="{{kb_article.links}}">{{::kb_article.title}}</a>

  3. In the Server script section replace the code:
    data.items = $sp.getKBCategoryArticleSummaries(data.category, data.limit + 1 , 250);
    with:
    var getDirect;    
        for(var count=0;count<data.items.length;count++) {
            getDirect = new GlideRecord('kb_knowledge');
            getDirect.addQuery("sys_id", data.items[count].sys_id);
            getDirect.query();

            if(getDirect.next()){
                if(getDirect.direct)
                    data.items[count].links = new KBPortalServiceImpl().getAttachmentLink(data.items[count].sys_id) ;
                    if(!data.items[count].links)
                        data.items[count].links = "?id=kb_article&sys_id="+data.items[count].sys_id;
            }
        }

Related Problem: PRB1365385