- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 09:45 AM
Hey everyone!
I am looking for a way to generate a PDF in flow designer with the new "Generate PDF Document" action in flow designer. I have created the document template, but not sure how the action works or what information needs to be placed into each of the fields.
The request is based on an SCTASK, the PDF can be generated where the tech only has to type in the information needed (4 boxes on the PDF). I cannot show the entire PDF, but here are 3 of the 4 boxes that they would like to be populated. The 4th box is the date that this is generated.
Can anyone help?
Thanks in advance!
Austin Brunet
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 06:26 AM
@Austin_Brunet I did some search and found that the Generate PDF Document action only works with HR Templates. Unfortunately, this action can't be leveraged for Catalog Tasks.
Here is the link to the thread https://www.servicenow.com/community/now-platform-forum/how-does-generate-pdf-document-action-works-...
For generating the PDF you will have to rely on PDFGenerationAPI. the https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server/sn_pdfgeneratorutils-namesp...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hey @Elena Spıru!
I believe I have!
You should be able to use the following script:
// Define variables
var recordSysId = [record_sysId],
pdfTemplateSysId = [pdfTemplateSysId], //Found in the sn_doc_pdf_template table
pdfName = [nameForPDF];
tableName = [table_name_of_recordSysId]
// Setup field mapping
var fieldMap = {
//This is where you map the field name from the PDF to the field name on the record
"form1[0].page1[0].Part1[0].userName[0]": [record_field_name].getDisplayValue(),
"form1[0].page1[0].typeReqDate[0]": [record_field_name].getDisplayValue(),
"form1[0].page1[0].Part1[0].Organization[0]": [record_field_name].getDisplayValue()
};
// Execute API
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var result = v.fillDocumentFields(fieldMap, pdfTemplateSysId, tableName, recordSysId, pdfName);
Hopefully that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 02:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 08:31 PM
@Austin_Brunet According to the snapshot of the Generate PDF Document, it accepts four parameters.
1. Task Record Id: You can provide the sys_id of your Catalog Task here
2. Template Id: Provide a reference to your Document Template here
3. Generate PDF Name: Provide the name of the PDF document here
4. Task Record Table: This should be Catalog Task (sc_task) in your case.
Please try executing your action with these inputs and see if it produces the desired result.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 10:02 AM
@Sandeep Rajput If I were to use variables from the SCTASK to fill in boxes in the PDF then generate the PDF based on those variables, would I include that somewhere else? Am I able to do that at all?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 12:10 PM
@Austin_Brunet You need to map your sc_task variables in the Template which you are going to use for the PDF generation in the Generate PDF Document action.
