GlideSysAttachment writeBase64 not working correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 07:09 AM
Hi !
I am having a problem using GlideSysAttachment writeBase64 function.
Currently, I am making a custom PDF using jspdf on the client side and then I am sending the body of the PDF to the server side using Ajax. On the server side, when I use GlideSysAttachment.write() with the required data and the string of the PDF's body, it works but the UTF-8 characters aren't correctly displayed. When I use writeBase64, nothing happens.
Is this the right way to do ?
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 07:29 AM
Hi,
can you try to update as this to ensure it is not UTF-8 encoding
var AttachAjaxUtil = Class.create();
AttachAjaxUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
attach: function() {
try {
// Parameters
var sysId = this.getParameter('sys_id');
var tableName = this.getParameter('table_name');
var filename = this.getParameter('filename');
var type = this.getParameter('type');
var attachment = "\uFEFF" + this.getParameter('attachment');
var rec = new GlideRecord(tableName);
rec.get(sysId);
var aId = new GlideSysAttachment().write(rec, filename, type, attachment);
return JSON.stringify({attachmentID: aId});
} catch (e) {
gs.log("AAU - Error : " + e.toString());
}
return null;
},
type: 'AttachAjaxUtil'
});
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 07:59 AM
It didn't work, sadly 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 08:42 AM
Hi,
then I doubt it can be achieved
Because in past I have tried this for text file and it worked with that workaround
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2021 01:00 AM
Yeah I think it doesn't work with PDF, sadly.
Thanks for your help anyway and if anyone finds a solution, please share!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2021 01:12 AM
Thanks for the update.
You can use this PDF customized solutions from links below
I am a creator — PDF Document Generator - Walter Brame
Use this share utility:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader