Create an UI action that will trigger the creation of a PDF Report, How?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 05:08 AM
Hello all.
I have a requirement to create an UI action that will trigger the creation of a PDF Report for that particular issue after it gets resolved. Fields that will be included in that PDF report should be set in system property. Font, font color etc. of the PDF Report would also need to be set in system property.
Any tips on this? What should be my approach?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 05:24 AM
Hello @Stefan Petkovic ,
var rec = new GlideRecord('sysauto_script');
rec.get('name', 'YOUR_JOB_NAME_HERE');
if (typeof SncTriggerSynchronizer != 'undefined')
SncTriggerSynchronizer.executeNow(rec);
else
Packages.com.snc.automation.TriggerSynchronizer.executeNow(rec);
Use this script in your ui action to hit your scheduled report.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2023 10:37 PM
Hello @Stefan Petkovic ,
Could you please try below script
Here's an example code snippet for generating a PDF document using GlidePDFDocument:
```
// Retrieve data for resolved incident
var gr = new GlideRecord('incident');
gr.get(current.sys_id);
// Define HTML template with variables populated by record data
var template = '<html><body>' + gr.number + ': ' + gr.short_description + '</body></html>';
// Create new PDF Document object
var pdfDoc = new global.GlidePDFDocument('MyReport.pdf');
// Set font and color properties
pdfDoc.setFontName(gs.getProperty("font.name"));
pdfDoc.setFontSize(gs.getProperty("font.size"));
pdfDoc.setColor(gs.getProperty("font.color"));
// Add content to PDF document
pdfDoc.addHTML(template);
// Save and close PDF document
pdfDoc.save();
pdfDoc.close();
// Attach generated PDF document to incident record
var attachmentSysId = new global.GlideSysAttachment().write(current, 'MyReport.pdf', 'application/pdf', pdfDoc.getBytes());
Thanks
Amarjeet Pal