
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 12:31 PM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 06:16 AM
@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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 08:28 PM
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.
Thanks again for your help. I really appreciate it.
Cyn

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 08:51 PM - edited 03-14-2024 08:51 PM
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();
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 09:55 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 06:16 AM
@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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 07:06 AM
Hi @Harsh Vardhan I did not know that thanks for the info.
Harish