KB Knowledge Article: Export an article to Word format (.docx)

Yass
Kilo Expert

Hello everyone,

I have a requirement that might be tricky:

Our customer is using the "Import Article" functionality to import and create a new KB article.

He wants one requirement :

In the KB article form, he wants:

  1. One button (UI action) called "Export to Word format (.docx)"
  2. This button will export the content of "Article body" HTML field to .docx format
  3. The Word (.docx) document downloaded has to be formating like HTML field and also if pictures are visible in the KB Article (so in "Article body" HTML field) they are to be visible in Word document exported

Did anyone already do this functionality or something close ?

Regards,

Yassine

6 REPLIES 6

Cody Smith _ Cl
Tera Guru

Hello Yass, 

You can try this modified version of a script that I found off of this question

UI Action to export to pdf

I am sure you can get this working with a .docx

function createDoc() {  
  var sysparm_table = g_form.getTableName();  
  var sysparm_sys_id = g_form.getUniqueValue().toString();  
  var url = sysparm_table + '.do?DOCX&sys_id=' + sysparm_sys_id;  
  window.open(url);  
}  

 

Let me know if you run into issues with this. 

 

If my answer was helpful, or solved your issue, please mark it as Helpful / Correct.
Thank you,
Cody Smith

Hi Cody,

I've a same requirement, above code in not working for me. I have created a UI Action with the following script. 

Could you please share the details about how could export form to Word.



Thanks,

Raj

 

Sarup Paul
ServiceNow Employee
ServiceNow Employee

What is the business use case to export an article into Word?

M_rio Rui Castr
Kilo Expert

Hello Yassine and Raj,

We created something similar for one customer. Its included in the app described in the following article: https://community.servicenow.com/community?id=community_article&sys_id=35679790db1bcc90414eeeb5ca961... 

  1. One button (UI action) called "Export to Word format (.docx)" - We have the "Generate file" button.
  2. This button will export the content of "Article body" HTML field to .docx format - You can configure the template to export also some other fields from the KA, alongside the "Article Body".
  3. The Word (.docx) document downloaded has to be formating like HTML field and also if pictures are visible in the KB Article (so in "Article body" HTML field) they are to be visible in Word document exported - The idea is that the KA is replicated in a Word file.

Kind regards,

MRC