Add 'Print Article' to Actions feature on knowledge article on Service Portal

cynlink1
Tera Expert

Hello,

 

I am trying to refill the following requirement:

 

  • Add new option named 'Print Article' under the Actions feature on the kb article in the Service Portal.

Is this possible? If yes, please let me know the best way to achieve it, ideally with step by step instructions.

 

Thanks,

Cyn

 

cynlink1_0-1709670587548.png

 

1 ACCEPTED SOLUTION

@cynlink1  I am using the exact same script on my personal instance and there is no syntax error on it.  Adding xml of my widget try to import it in your instance. 

 

If you are doing in on personal instance, I can quickly check it , please let me know. 

 

Note: Just for information => is a fat arrow function symbol and if you replace with == operator it will definitely not going to work . 

 

Let me know if you have any further question for me. 

 

Thanks,

Harsh

 

View solution in original post

22 REPLIES 22

Hi Harsh,

 

I am using your code. When I attempted to save the updated Client Controller function c.printArticle(), it get an error message related to a syntax error in line 20.

 

I am not sure what I am doing wrong. I copied and pasted it. 

cynlink1_1-1710473203512.png

 

Thanks again for your help. I really appreciate it.

Cyn

 

 

 

Hi @cynlink1 there is a syntax error on line 20, corrected below

c.printArticle = function(myID) {
var originalHTML = document.body.innerHTML;
document.body.innerHTML = document.getElementById(myID).innerHTML;
document.querySelectorAll('.title-secondary-data')
.forEach(title == title.remove()) //  .forEach(title => title.remove())
window.print();
document.body.innerHTML = originalHTML;
window.location.reload();
}

Regards
Harish

Hi Harish,

 

Thanks for the response. I was allowed to save without encountering a syntax error. However when I tested the functionality, the print dialog box no longer popped up. Instead, I was redirected back to the article. 

 

BEFORE making any changes, it was working with the original code and the print dialog appeared as shown below. 

cynlink1_0-1710478332488.png

 

@cynlink1  I am using the exact same script on my personal instance and there is no syntax error on it.  Adding xml of my widget try to import it in your instance. 

 

If you are doing in on personal instance, I can quickly check it , please let me know. 

 

Note: Just for information => is a fat arrow function symbol and if you replace with == operator it will definitely not going to work . 

 

Let me know if you have any further question for me. 

 

Thanks,

Harsh

 

Hi @Harsh Vardhan I did not know that thanks for the info. 

Regards
Harish