how to solve this error"maximum permitted size of 33554432"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 06:23 AM - edited 12-28-2023 11:07 PM
bhgetestmail788 - grattach.sys_id*****wdwdwdwdwdwdwdwdwd
Javascript compiler exception: String object would exceed maximum permitted size of 33554432 in: var tablesysid = "axyzwwwwswswsw"; var grattach= new GlideRecord('sys_attachment'); grattach.addQuery('table_sys_id', tablesysid);
HI all,
using this code:
var tablesysid = "xyz";
var grattach= new GlideRecord('sys_attachment');
grattach.addQuery('table_sys_id', tablesysid);
grattach.query();
if (grattach.next()) {
gs.log("testmail788 - grattach.sys_id*****" + grattach.sys_id.toString());
// Code to get Base64encoded content
var StringUtil1 = new GlideStringUtil();
var gsis1 = GlideSysAttachmentInputStream(grattach.sys_id.toString());
var ba1 = new Packages.java.io.ByteArrayOutputStream();
gsis1.writeTo(ba1, 0, 0);
ba1.close();
var encData = StringUtil1.base64Encode(ba1.toByteArray());
var encData10 = "\"" + encData + "\"";
gs.log("testmail788 - encData" +encData);
}
passing encdata via rest message .Kindly help me

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 06:48 AM
hi @Debarpita,
Issue is occurred due to :
- The platform has a hardcoded value of 32 MB for the String object and it is not customizable via any system property.
- This issue has been mostly seen to happen when script includes are instantiated in a while loop. Note that the limit may be breached when other scripts invoke a "ScriptableObject", for example instantiating a script include, in a while/for loop where a GlideRecord object is passed into the script include inside the while loop. The object size grows with each loop iteration because we are adding up the GlideRecord object with each loop. One way to cause this is to loop with each GlideRecord result, and then call a script include.
- This error will also occur if you assigned a lot of data to a new glide record object
It can be resolved by making sure that what every string object defined doesn't grow beyond 32 MBs in any of the server side scripting.
NOTE: Javascript uses 2 bytes per character and there is a String object limit of 33554432 bytes.
Please mark it helpful and accept it as solution
Thanks and Regards
Akash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 06:50 AM
no need to change any system property?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 06:52 AM
platform has a hardcoded value of 32 MB for the String object and it is not customizable via any system property.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2023 06:52 AM - edited 02-15-2023 06:53 AM
Hi have also use this code:
var sysIDOfRecord = tablesysid;
var gsa = new GlideSysAttachment();
var bytesInFile = gsa.getBytes(current);
var dataAsString = Packages.java.lang.String(bytesInFile);
dataAsString = String(dataAsString);
var StringUtil = new GlideStringUtil();
var encData = StringUtil.base64Encode(dataAsString)
but upto 5mb working fine after 5mb it is not working. please suggest on this