- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎01-23-2025 09:00 AM
Often, we need to configure a document template for a table and generate a PDF file to attach to the target record using server-side scripting.
Here's how you can generate and attach the document template file to the target record. This works in both global & scoped app.
//recordId - Sys ID of the target record. This record must be from the table defined in the document template.
//documentTemplateId - Sys ID of the document template to use for pdf generation.
//pdfName - Name of the pdf file
var recordId = 'a9a16740c61122760004fe9095b7ddca';
var documentTemplateId = '50e6c385db175e10727ee7dcd39619f2';
var pdfName = 'INC_Template.pdf';
new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);
Output:
- 2,565 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
When I created document template for Request table and try to run this background script.the pdf document shows with html tags it doesnot show in right format.Can someone help me what is the issue here?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @Ankur Bawiskar
for suppose in document template (table is incident)
using background script
var recordId = 'a9a16740c61122760004fe9095b7ddca';(sys_id of the problem which is having incident as parent)
var documentTemplateId = '50e6c385db175e10727ee7dcd39619f2';
var pdfName = 'INC_Template.pdf';
new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);
can we generate document for problem record
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
it should be on same table i.e. Document template (incident) and Target Record also same
I haven't tested when both are different.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
How can we use it for RITM and send email to user with pdf.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Ankur Bawiskar can you help how to use this for RITM and send email to user with these pdf.
I am using below background script to generate 2 pdfs
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi @Ankur Bawiskar , Actually I'm using the same functionality in the flow designer i.e. created input variables, script step used the same script passed the input values and mapped it. Getting the output , but the issue is it is not working as system user , the generated record id comes as Blank.