How to generate page number in the pdf through "Generate PDF" button on Impact analysis table(BCM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
did you check which API is used to generate? the UI action script image is not clear
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi , Below is the UI action code of Generate PDF button
var pdfUtils = new sn_bia.GenerateBiaPdfUtil(current.sys_id); var defaultTemplateName = pdfUtils.getPDFTemplateName(); var escapedName = new sn_bcm.BCMUtils().escapeHTML(current.getValue("name")); var result = pdfUtils.generateDocument(escapedName, defaultTemplateName); current.update(); action.setRedirectURL(current); if (result.attachmentId && result.downloadLink) { gs.addInfoMessage(gs.getMessage('<div style="display: inline-block;">{0} PDF has been successfully generated for download</div>', result.downloadLink)); } else { gs.addErrorMessage(gs.getMessage('Error: Unable to generate PDF attachment')); }And document template name is "BIA PDF Template"
var GenerateBiaPdfUtilBase = Class.create(); GenerateBiaPdfUtilBase.prototype = { initialize: function(biaSysId) { this.impactAnalysisTable = 'sn_bia_analysis'; this.documentTemplateTable = 'sn_doc_template'; this.biaSysId = biaSysId; this.FILE_EXTENSION = '.pdf'; }, getPDFTemplateName: function() { return "BIA PDF Template"; },Below is the source code of the template
<p style="text-align: center;"><span style="font-family: 'times new roman', times; font-size: 12pt;"><img style="align: baseline;" src="01-ServiceNow_logo_STANDARD_RGB_RM_GG+A_02202020.jpgx" width="630" height="193" align="baseline"></span></p> <p style="text-align: center;"> </p> <p style="text-align: center; font-size: 36pt; font-family: arial, helvetica, sans-serif; color: #008541;"> </p> <p style="text-align: center; font-size: 36pt; font-family: arial, helvetica, sans-serif; color: #008541;"><span style="font-family: 'times new roman', times; color: #233e41;"><strong>${name}</strong></span></p> <p style="text-align: center;"> </p> <p style="text-align: center;"> </p> <p style="text-align: center;"> </p> <p style="text-align: center;"> </p> <p style="text-align: center;"><span style="font-family: 'times new roman', times; font-size: 18pt; padding-left: 16px;"><span style="font-family: 'times new roman', times; padding-left: 16px;">Date: ${template_script:getCurrentDateBCM}</span></span></p> <p style="text-align: center;"> </p> <p style="text-align: Right;"> </p> <div style="page-break-before: always;"><span style="font-family: 'times new roman', times; font-size: 14pt; padding-left: 16px;"><span style="font-size: 12pt;"><span style="font-family: 'times new roman', times; font-size: 12pt; padding-left: 16px;">${template_script:getBIAStyles}</span></span></span></div> <h2 style="font-size: 20pt; font-family: 'times new roman', times; color: black; background-color: #d5ecef; padding: 10px 6px; text-align: left; font-weight: normal;"> 1. Details</h2> <p><span style="font-family: 'times new roman', times; font-size: 14pt; padding-left: 16px;"><span style="font-size: 12pt;"><span style="font-family: 'times new roman', times; font-size: 12pt; padding-left: 16px;">${template_script:getBIADetails}</span></span></span></p> <h2 style="font-size: 20pt; font-family: 'times new roman', times; color: black; background-color: #d5ecef; padding: 10px 6px; text-align: left; font-weight: normal;"> 2. Impact Assessments</h2> <div id="dtblock_d70b00957b421210c561f3e7248cb6c8_1732279374522_dtblock" class="dt-block-content-item mceNonEditable" style="border: 1px solid #ddd; padding: 10px; margin: 5px 0; disabled: true; display: block; color: rgb(var(now-color--neutral-14,var(--now-color_surface--neutral-6,53,59,73))); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; line-height: 1.42857; font-weight: bold; width: 95%;" tabindex="0" data-dt-type="dtblock" data-dtblock-id="d70b00957b421210c561f3e7248cb6c8"> <div class="block-info" style="display: inline-block; vertical-align: top;" data-dt-type="dtblockcontent"> <div class="block-text-title">BIA with legacy assessment</div> <div class="description" style="font-weight: 100;">Document block to show legacy assessments in PDF</div> </div> </div> <div id="dtblock_105bcc557b421210c561f3e7248cb636_1732279803177_dtblock" class="dt-block-content-item mceNonEditable" style="border: 1px solid #ddd; padding: 10px; margin: 5px 0; disabled: true; display: block; color: rgb(var(now-color--neutral-14,var(--now-color_surface--neutral-6,53,59,73))); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; line-height: 1.42857; font-weight: bold; width: 95%;" tabindex="0" data-dt-type="dtblock" data-dtblock-id="105bcc557b421210c561f3e7248cb636"> <div class="block-info" style="display: inline-block; vertical-align: top;" data-dt-type="dtblockcontent"> <div class="block-text-title">BIA with smart assessment</div> <div class="description" style="font-weight: 100;">Document block to show smart assessments in PDF</div> </div> </div> <h2 style="font-size: 20pt; font-family: 'times new roman', times; color: black; background-color: #d5ecef; padding: 10px 6px; text-align: left; font-weight: normal;"> 3. Dependencies</h2> <p><span style="font-family: 'times new roman', times; font-size: 12pt;">This section details the underlying dependencies as identified by the BIA owner. The dependencies are categorised and are needed for keeping the asset in scope up and running during a usual business day. </span></p> <p><span style="font-family: 'times new roman', times; font-size: 12pt; padding-left: 16px;">${template_script:getDependencySectionForBIA}</span></p> <h2 style="font-size: 20pt; font-family: 'times new roman', times; color: black; background-color: #d5ecef; padding: 10px 6px; text-align: left; font-weight: normal;"> 4. Contributors</h2> <div><span style="font-size: 12pt; font-family: 'times new roman', times;">This section lists the people who have contributed to the creation of this BIA.</span></div> <p><span style="font-family: 'times new roman', times; font-size: 12pt; padding-left: 16px;">${template_script:getBIAContributors}</span></p> <h2 style="font-size: 20pt; font-family: 'times new roman', times; color: black; background-color: #d5ecef; padding: 10px 6px; text-align: left; font-weight: normal;"> 5. Attachments</h2> <p><span style="font-family: 'times new roman', times; font-size: 12pt;">Following are the attachments added to the BIA by the BIA owner.</span></p> <p><span style="font-family: 'times new roman', times; font-size: 12pt; padding-left: 16px;">${template_script:getBIAAttachments}</span></p> <p> </p> <p> </p>Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
if it's out of the box button then you can inform customer the behavior
it's better you create your own button with your logic rather than touching OOTB
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Ankur Bawiskar Client is asking to customise or do anything to get the page number, What we can do to bring page number?