Maximum file size to convert to base64 in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 04:25 AM
What is the Maximum file size to convert to base64 in servicenow? i tried with 2MB and 3MB but it is not converting to base64. Please help me in this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 10:45 PM
Thanks Ankur Bawiskar. It worked for me.
Can we also use similar approach to combine two pdf files. please advice or any other solution in servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2020 11:13 PM
Hi Ramesh,
just a note to above comment; I haven't tried for files larger than 18/19MB.
Possibly there is some limit of 20MB you can get to know that since ServiceNow internally has limit how much string value a variable can hold
Nope you cannot use similar approach to combine 2 pdf files;
check below links:
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
02-05-2020 04:18 AM
Thanks for the links. Am completed with converting 4 files to base64 which all are around 12MB, now am placing in json format but am not getting final json format.
var gliObj = new GlideRecord('sys_attachment');
gliObj.addQuery('table_name', 'dms_document_revision');
gliObj.addQuery('table_sys_id', '405a9589db764890d17be1c2ca96197a');
gliObj.query();
var reqObj = {};
var reqArr = [];
while (gliObj._next()) {
var StringUtil = new GlideStringUtil();
var gsis = GlideSysAttachmentInputStream(gliObj.sys_id.toString());
var ba = new Packages.java.io.ByteArrayOutputStream();
gsis.writeTo(ba, 0, 0);
ba.close();
var base64EncodedData = StringUtil.base64Encode(ba.toByteArray());
var obj = {};
obj.docName = "doc.pdf";
obj.format = base64EncodedData;
reqArr.push(obj);
}
gs.info('xresp:executed'+reqArr);
reqObj.objPdf = reqArr;
gs.info('final json format:' + JSON.stringify(reqObj));
am unable to get the final json format. Please advice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2020 04:41 AM
Hi Ramesh,
possibly because the json string is long enough hence it is not printing
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
02-05-2020 04:44 AM
am getting below error:
"Javascript compiler exception: String object would exceed maximum permitted size of 33554432".
can we increase the size limit or
Is there any other way to get the final json.?
kindly advice