Need to generate a word document letter

Raj40
Tera Contributor

Hi,

I have a requirement where need to generate a Word format letter based on a record. We are using a custom table to record requests created by the users. The letter will kind of like a official letter template as well. Is there any out of box feature which can be used to achieve the requirement? or any word doc generator using script

Thank you

Raju

3 REPLIES 3

Allen Andreas
Administrator
Administrator

Hi,

I don't believe there's a "Word" doc generator, but you can create a PDF, XML, txt document, but that's about it.

There may be an app on the SN store that does it, but not out of the box and provided by ServiceNow.

Please mark reply as Helpful/Accept Solution, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Raghuveer Moort
ServiceNow Employee
ServiceNow Employee

There is an App in ServiceNow Store (link below) that can help meet your requirement. 

 

https://store.servicenow.com/sn_appstore_store.do#!/store/application/ee4c20c91b304050031fdb16cc4bcb...

 

Also, there is an Idea already submitted in the past (click here) for the same requirement and currently it is under review by the Product team

ali bhatti
Tera Contributor

 

I recently worked on a requirement where I needed to generate an official letter (Word format) from a record in a custom table in ServiceNow. I’m sharing the full solution here in case it helps someone with a similar use case.

The best part? No scripting required – this is all done using ServiceNow's built-in Document Templates feature.


 Use Case

Let’s say you have a custom table like u_request_letter where users submit request forms. You want to create a downloadable .docx letter for each record (such as approval letters, certificates, summaries, etc.).


🛠 Steps to Implement

🔹 Step 1: Activate Document Templates Plugin

  1. Go to System Definition > Plugins

  2. Search for: Document Templates

  3. Activate the plugin: com.glide.document_generator


🔹 Step 2: Create a Word (.docx) Template

  1. Open Microsoft Word

  2. Write your letter format and use placeholders like ${user_name}, ${request_number}, etc.

  3. Save the file as: Request_Letter_Template.docx

📝 Example content:

 

 
Dear ${user_name}, Your request (${request_number}) has been approved. Request Type: ${request_type} Status: ${state} Description: ${short_description} Regards, ServiceNow Team
 

🔹 Step 3: Create the Document Template in ServiceNow

  1. Go to Document Templates > Document Templates

  2. Click New

  3. Set the table to your custom table (e.g., u_request_letter)

  4. Upload your .docx file

  5. Submit the form

  6. Open it again and click Auto-map fields


🔹 Step 4: (Optional) Add a Button to Generate the Document

To let users generate the letter directly from the form:

  1. Go to System Definition > UI Actions

  2. Create a new UI Action:

    • Table: Your custom table

    • Name: Generate Letter

    • Action type: Form Button

    • Script:

      var generator = new sn_docgen.DocumentGenerator(); var output = generator.generateTemplate('<YOUR_TEMPLATE_SYS_ID>', current.sys_id); action.setRedirectURL(output.url);
    • Replace <YOUR_TEMPLATE_SYS_ID> with the actual Sys ID of your uploaded template.


 

Now when you click the "Generate Letter" button on a record, ServiceNow will generate a Word document with values filled in from the record. You can also use Flow Designer to send this as an email attachment if needed.

 

 

Pro Tips

  • You can use dot-walking for related fields like ${caller.name}.

  • Make sure field names in the template match the ones in your table.

  • The document can also be auto-generated through Flow using the Generate Document action.

Happy building! 
— Saadat Ali —