function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dinesh Voonna 17Dinesh Voonna 17 

String length exceeds maximum: 6000000

Hi,
I am getting this Error "String length exceeds maximum: 6000000" while I am converting Body of an attachment to String.
Please find my code and Screen shot.
Please help me, how to fix this error.
 
Code:-
reportAttachment = [SELECT Id, Name, Body, ContentType FROM Attachment WHERE ParentId = :idReport];
    public string getReportBody() {
        return reportAttachment.get(0).Body.toString();
    }
Screen Shot:-

 User-added image
Amit VaidyaAmit Vaidya
Hi Dinesh,

Please look this, if this(http://www.ceus-now.com/string-length-exceeds-maximum-6000000/) is helpful for you. 
Dinesh Voonna 17Dinesh Voonna 17
Hi Amit,
Thanks for the Article. But I don't want to use third party tools. Using Salesforce functionality, can it be possible?
Amit VaidyaAmit Vaidya
Hi Dinesh,

This is the limitation of Salesforce. The largest amount of text that can be displayed in one textarea element is 6 million characters.
Amit VaidyaAmit Vaidya
You needs to reduce the maximum file size that's only the solution.