How to Generate and Embed a QR Code in a Document Template in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 03:44 AM
📎 How to Generate and Embed a QR Code in a Document Template in ServiceNow
This article explains how to dynamically generate a QR Code in ServiceNow and embed it into a Document Template using a Document Template Script. This is useful for adding QR codes to PDF or Word documents such as tickets, receipts, confirmations, or forms.
🔹 Step 1: Import and Commit the Update Set
- attached file
🔹 Step 2: Insert the QR Code Placeholder in Your Document
- Navigate to All → Document Template → Document Template.
- Open the required document template record.
- In the Template Body field, insert the following placeholder where the QR Code should appear:
🔹 Step 3: Create the Document Template Script
Navigate to All → Document Template → Document Template Scripts and click New. Use the following script:
- Name: qrGeneration
- Applies to: Set the relevant table (e.g., Case, Task)
🔹 Step 4: Test the Document Generation
- Navigate to All → Document Template → Document Template.
- Open your configured document template.
- Click the Preview button.
- Select a specific record (e.g., case or task).
- Click Generate.
📌 Summary
Step Action
| 1 | Import the update set and commit it |
| 2 | Insert ${template_script:qrGeneration} in the document template |
| 3 | Create the Document Template Script using HtmlRenderQRCode() |
| 4 | Use the Preview button and test with a specific record |
- 3,508 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi,
I may be doing something wrong, but when I import the update set in my DPI I see 0 updates.
Regarding your solution, can it be used to render QR codes in notifications?
Thank you and kind regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @amrfahmy2 ,
Thanks for sharing this! This is a helpful approach for dynamically generating QR codes in Document Templates.
One thing I'd add is to ensure the glide.servlet.uri system property is configured correctly, as the generated QR code relies on it to build the record URL. Also, make sure the Document Template Script is applied to the correct table; otherwise, the placeholder won't render during document generation.
Overall, this is a simple and effective solution for embedding QR codes into generated PDF or Word documents without requiring additional custom integrations.