Need help generating a PDF and attaching to a record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 12:58 PM
I have a custom table u_pco. I created a widget and a service portal page to display the contents of the record in a letter format. I currently have a UI action thats working nicely to display and send the print command for the url. however, i have a need to have a button to generate a PDF of the page and attach it to the record, so that it can be sent out via an email notification.
Does anyone know how i can adjust this print client script to generate a pdf of the service portal page and attach it to my current record without user intervention (except clicking of the button to trigger)
my UI Action script:
function PrintPCOLetter(){
if(g_form.modified){
alert("Please save the form before continuing");
return false;
}
var url = 'sp?id=pc_letter&sys_id='+g_form.getUniqueValue()+"&print=false";
window.open(url, "_self");
//g_navigation.openPopup(url);
return false;
}
about this simple script: the script, ensures that the form isnt "dirty before allowing to proceed"
then sets the URL to goto the service portal page "pc_letter" and grabs the sys id and print parameter that the widget is using to a) get the desired record, and the print=false advises to show the letter, not print it using system dialog once loaded. (if print=true then the system dialog will automatically send the page to the system print dialog, allowing the user to choose which printer and see a preview)
- Labels:
-
User Experience and Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 01:29 PM
You can use below PDF utils to create pdf file and attach it to record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 01:44 PM
i saw that option, but its looking for an html string, i have a whole html page, with CSS to style it, that i cant figure out how to use that as the page to create a pdf from. any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 01:55 PM
Yes, you can pass everything as string. Refer below script and file generate from this script.
var html = "<html><head><style>body {background-color: lightblue;h1 {color: white;text-align: center;}p {font-family: verdana;font-size: 20px;}</style></head><body><h1>My First CSS Example</h1><p>This is a paragraph.</p></body></html>";
var v = new sn_pdfgeneratorutils.PDFGenerationAPI;
var hfInfo = new Object();
var result = v.convertToPDFWithHeaderFooter(html, "incident", "7b5a0cdf2fc1c110c767bac62799b60b", "myPDF", hfInfo);
gs.info(JSON.stringify(result));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 02:02 PM
can i pass variables from my record into this script? i have to show this html page AND have a pdf option, id like to not have to keep two html codes in synch when changes are requested to the document. if i can point to my service portal page to get the content, that would be more ideal.