how to make pdf file using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
Im trying to make a pdf file using business rule.
When Im using this function in my PDI, its working well:
var pdfAPI = new sn_pdfgeneratorutils.PDFGenerationAPI();
var result = pdfAPI.convertToPDF(
html.join(''),
current.getTableName(),
current.getUniqueValue(),
fileName
);
But when Im trying to implement this on my client's instance (they are working on premise and not in the cloud) its not working.
Any idea why or if there is another way to make a pdf file without this function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Alon,
What happens on their instance, do you get an error, a blank PDF, or nothing attached at all?
Two things worth checking meanwhile. If your business rule sits in a scoped app, calls into sn_pdfgeneratorutils need a cross-scope privilege record, and without it the call just fails quietly. On your PDI it's probably in global, which would explain why the same code runs there.
The other one is glide.pdf.url.whitelisting.enabled. If that's true, anything the HTML pulls in from a URL gets dropped unless it's listed in com.snc.pdf.whitelisted_urls. Locked down instances often have it switched on.
Logging what convertToPDF returns and checking the system log at that time usually points straight at the cause.
https://www.servicenow.com/docs/r/api-reference/server-api-reference/PDFGenerationAPIBothAPI.html
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
hey @Alon Grod
Please check whether the PDF Generation Utilities plugin (com.snc.apppdfgenerator) is installed and active.
Also check the System Logs for the exact error returned by convertToPDF().
*************************************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Alon Grod ,
Could you please share a screenshot or the relevant logs showing exactly what is going wrong? This will help us understand and troubleshoot the issue more effectively.
