How to add copy Permalink on service portal KB Article

Appu
Tera Guru

Hi all,

I wanted to add the 'copy Permalink' to my service portal KB Article
is there any plugin that needs to be activated or is it to be coded

currently, my KB looks like this

Any suggestions would be helpful

Thankyou

find_real_file.png

6 REPLIES 6

Copy permalink button as well comes with OOTB 'Knowledge Article Content' portal widget if you activate free 'Knowledge Management - Service Portal' plugin.

Ct111
Giga Sage

Hello,

 

OOB widget  has a copy permalink feature by default . But incase your customized widget missed that then

crosscheck it by  comparing with OOB widget  KNOWELDGE ARTICLE CONTENT

 

In HTML template the code for Permalink is somewhere like this

   <p class="pull-right kb-permalink" ng-if="::!c.isMobile"><a href="javascript:void(2)" ng-click="c.copyPermalink()">{{::data.messages.COPY_PERMALINK}}</a></p>

 

In Server Script 

data.messages.COPY_PERMALINK = gs.getMessage("Copy Permalink");

 

In Client Side

c.copyPermalink = function(){
var v = document.createElement('textarea');
var permalink = document.location.origin + document.location.pathname + '?id='+c.data.params.sysparm_article_view_page_id+'&sysparm_article=' + $scope.data.number;
v.innerHTML = permalink;
v.className = "sr-only";
document.body.appendChild(v);
v.select();
var result = true;
try {
result = document.execCommand('copy');
}
catch(err){
result = false;
}
finally{
document.body.removeChild(v);
}
if(result === true){
c.showUIMessage('info', c.data.messages.PERMALINK_COPIED);
}
else{
$window.prompt("${Because of a browser limitation the URL can not be placed directly in the clipboard. Please use Ctrl-C to copy the data and escape to dismiss this dialog}", permalink);
}

};

 

But it does have dependency on other lines as well so better check that. And also dont forget to crosscheck

angular templates.

Mark my ANSWER as CORRECT and hELPFUL if it helps