How to add copy Permalink on service portal KB Article
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2021 10:36 PM
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
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2021 10:33 AM
Copy permalink button as well comes with OOTB 'Knowledge Article Content' portal widget if you activate free 'Knowledge Management - Service Portal' plugin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2021 03:44 AM
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