Maximum file size to convert to base64 in servicenow

Ramesh R
Tera Contributor

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.

21 REPLIES 21

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.

 
 

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:

https://community.servicenow.com/community?id=community_question&sys_id=b90dbbd1db0363409a64e15b8a96...

https://community.servicenow.com/community?id=community_question&sys_id=72831b6cdbe85b004fc2f4621f96...

https://community.servicenow.com/community?id=community_question&sys_id=4133497fdbe7b7080be6a345ca96...

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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.

 

Hi Ramesh,

possibly because the json string is long enough hence it is not printing

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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