From dc384f8ccb3bac705356cd75626fbaab172534ba Mon Sep 17 00:00:00 2001
From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com>
Date: Tue, 21 Oct 2025 15:18:36 -0500
Subject: [PATCH 1/4] Add README for PDF generation using PDFGenerationAPI
---
Client-Side Components/UI Actions/Generate a PDF/README.md | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 Client-Side Components/UI Actions/Generate a PDF/README.md
diff --git a/Client-Side Components/UI Actions/Generate a PDF/README.md b/Client-Side Components/UI Actions/Generate a PDF/README.md
new file mode 100644
index 0000000000..c67fe02e24
--- /dev/null
+++ b/Client-Side Components/UI Actions/Generate a PDF/README.md
@@ -0,0 +1,3 @@
+Generating a PDF using PDFGenerationAPI
+Calling an OOTB convertToPDFWithHeaderFooter() method to generate a PDF with your header and footer.
+PDFGenerationAPI – convertToPDFWithHeaderFooter(String html, String targetTable, String targetTableSysId, String pdfName, Object headerFooterInfo, String fontFamilySysId, Object documentConfiguration)
From 1e75967d8ba38bd79112c20c30356ea3cf1a612e Mon Sep 17 00:00:00 2001
From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com>
Date: Tue, 21 Oct 2025 15:23:33 -0500
Subject: [PATCH 2/4] Add PDF generation for related incidents
Implement PDF generation for incidents related to a change request using ServiceNow's PDFGenerationAPI.
---
.../UI Actions/Generate a PDF/serverscript.js | 50 +++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 Client-Side Components/UI Actions/Generate a PDF/serverscript.js
diff --git a/Client-Side Components/UI Actions/Generate a PDF/serverscript.js b/Client-Side Components/UI Actions/Generate a PDF/serverscript.js
new file mode 100644
index 0000000000..66c8378e1c
--- /dev/null
+++ b/Client-Side Components/UI Actions/Generate a PDF/serverscript.js
@@ -0,0 +1,50 @@
+//Table: Change Request
+// UI action button on the change form that exports all the related incidents into a PDF format.
+//ServiceNows PDFGenerationAPI allows you to customize the page size, header, footer, header image, page orientation, and more.
+
+var inc = new GlideRecord('incident'),
+ incidentsList = [],
+ v = new sn_pdfgeneratorutils.PDFGenerationAPI,
+ html = '',
+ hfInfo = new Object(),
+ result;
+inc.addQuery('rfc', current.sys_id);
+inc.query();
+while (inc.next()) {
+ incidentsList.push(inc.number);
+ incidentsList.push(inc.getDisplayValue('caller_id'));
+ incidentsList.push(inc.getDisplayValue('category'));
+ incidentsList.push(inc.getDisplayValue('subcategory'));
+ incidentsList.push(inc.getValue('priority'));
+ incidentsList.push(inc.getValue('short_description'));
+ incidentsList.push(inc.getValue('description'));
+ incidentsList.push(inc.getDisplayValue('assignment_group'));
+}
+var json = {
+ incidents: incidentsList.toString()
+};
+
+ JSON.stringify(json);
+html = '
Incidents Related to the Change: ' + current.number + '
';
+
+
+html += '';
+html += '| Number | Caller | Category | Sub Category | Priority | Short Description | Description | Assignment Group |
' + getIncidentsTable(json.incidents) + '
';
+hfInfo["FooterTextAlignment"] = "BOTTOM_CENTER";
+hfInfo["FooterText"] = "Incidents List";
+hfInfo["PageOrientation"] = "LANDSCAPE";
+hfInfo["GeneratePageNumber"] = "true";
+
+result = v.convertToPDFWithHeaderFooter(html, 'change_request', current.sys_id, "Incidents Related to the Change:_" + current.number, hfInfo);
+action.setRedirectURL(current);
+
+function getIncidentsTable(incidents) {
+ if (incidents == '')
+ return '';
+ var table = '',
+ i;
+ incidents = incidents.split(',');
+ for (i = 0; i < incidents.length; i += 8)
+ table += '| ' + incidents[i] + ' | ' + incidents[i + 1] + ' | ' + incidents[i +2] + ' | ' + incidents[i + 3] + ' | ' + incidents[i + 4] + ' | ' + incidents[i + 5] + ' | ' + incidents[i + 6] + ' | ' + incidents[i + 7] + ' |
';
+ return table;
+}
From ab07f4f7ba94fd6e6e52012e4c329c1f69554f18 Mon Sep 17 00:00:00 2001
From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com>
Date: Tue, 21 Oct 2025 15:25:09 -0500
Subject: [PATCH 3/4] Update README with example image for PDF generation
Added example image to README for PDF generation.
---
Client-Side Components/UI Actions/Generate a PDF/README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Client-Side Components/UI Actions/Generate a PDF/README.md b/Client-Side Components/UI Actions/Generate a PDF/README.md
index c67fe02e24..bd82e8b673 100644
--- a/Client-Side Components/UI Actions/Generate a PDF/README.md
+++ b/Client-Side Components/UI Actions/Generate a PDF/README.md
@@ -1,3 +1,7 @@
Generating a PDF using PDFGenerationAPI
Calling an OOTB convertToPDFWithHeaderFooter() method to generate a PDF with your header and footer.
PDFGenerationAPI – convertToPDFWithHeaderFooter(String html, String targetTable, String targetTableSysId, String pdfName, Object headerFooterInfo, String fontFamilySysId, Object documentConfiguration)
+
+Example:
+
+
From a90f00dbc0fdbf4aac5e0bba779aa56457553e70 Mon Sep 17 00:00:00 2001
From: HackoDev1530 <92592691+HackoDev1530@users.noreply.github.com>
Date: Tue, 21 Oct 2025 15:26:01 -0500
Subject: [PATCH 4/4] Add introduction section to PDF generation README
Added an introduction section to the README for clarity.
---
Client-Side Components/UI Actions/Generate a PDF/README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Client-Side Components/UI Actions/Generate a PDF/README.md b/Client-Side Components/UI Actions/Generate a PDF/README.md
index bd82e8b673..2a61438b92 100644
--- a/Client-Side Components/UI Actions/Generate a PDF/README.md
+++ b/Client-Side Components/UI Actions/Generate a PDF/README.md
@@ -1,7 +1,8 @@
+# Introduction
Generating a PDF using PDFGenerationAPI
Calling an OOTB convertToPDFWithHeaderFooter() method to generate a PDF with your header and footer.
PDFGenerationAPI – convertToPDFWithHeaderFooter(String html, String targetTable, String targetTableSysId, String pdfName, Object headerFooterInfo, String fontFamilySysId, Object documentConfiguration)
-Example:
+# Example: