How to update PDF Template to a new version and keeping the mapped fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2023 11:59 PM - edited 05-22-2023 12:35 AM
I am trying to make out how to use PDF Template (sn_doc_pdf_template) in an efficient way. I am having some logic to generate PDF docs from this template and related mappings.
I don't understand how I can update the template to a new version keeping the generated mappings. 70+ mappings.
It is not possible to delete the attached attachment as normal using "Manage attachment". It is possible to upload a new though. If I want to create a new version I need to create a new record in PDF Template and generate new mappings. But then I need to manually go through all mappings and update them again. One workaround my be to go to the old PDF Template and change the mappings to point to the new PDF Template (haven't tried it yet). But then I need to change the reference to the PDF Template from some logic.
Do note that uploading the template to the Document field of the record doesn't create an attachment in the sys_attachment.
I assume there must be a way to create a new version without need to manually update all mappings again. How?
UPDATE:
I am using sn_doc.siDocumentTemplateUtility().generatePDFFromDocumentTemplate() to generate the document. I post which PDF Template record to use as a parameter in that function, not which sys_attachment record to use. Hence, you cannot add more than one template file to that PDF Template record since the logic selects one attachment from that record. I guess one have to think the selection is random. And since you cannot delete the attachment there will be plus one attachment when you upload the new version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 12:09 AM
1. Download the new version of the PDF template
2. Map the fields of the new version to the existing fields in ServiceNow
3. Update the PDF template in ServiceNow
4. Publish the new version of the PDF template
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 12:34 AM
Thanks' for the response!
I am using sn_doc.siDocumentTemplateUtility().generatePDFFromDocumentTemplate() to generate the document. You post which PDF Template record to use as a parameter in that function, not which sys_attachment record to use. Hence, you cannot add more than one template file to that PDF Template record since the logic selects one attachment from that record. I guess one have to think the selection is random. And since you cannot delete the attachment there will be plus one attachment when you upload the new version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2024 12:49 AM
Hi Niklas6,
If it can help, I had the same problem, during each modification on the pdf template.
The only solution I found in order not to redo all the mappings, is:
- Export in .XML the mappings from the table "https://[instance].service-now.com/sn_doc_pdf_template_mapping_list.do", linked on the "Document template" field
- Update the new pdf document
- Perform the "Parse PDF"
- Keep only the new fields created (modifications), and delete the already existing mappings.
- Return to "https://[instance].service-now.com/sn_doc_pdf_template_mapping_list.do" and re-import the .XML saved before
It works for me