You need to sign in to do that
Don't have an account?

email service failing with STRING_TOO_LONG
I created an email service to attach emails as taks to a custom object. It works great unless the email content is too large, then the email bounces and I recevie an error email "System.DmlException: Insert failed. First exception on row 0; first error: STRING_TOO_LONG, Description: data value too large: max length=32000" Is there anyway to code around this and have the "myplaintext" content truncated before the email is attached or to strip out the salutation? I tried playing around with the myplaintextistruncated command but that didn't help.
You can probably use the substring method to return only the first 32000 characters. Something like this:
string myplaintext = '............';
return myplaintext.substring(0,32000);
This will return only 32000 characters.
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank
Substring can only take string as an argument. Please convert your value into a string first and then pass it into the substring method. Please try this and check. Also, it would help if you can provide your code in a more readable format :)
Thanks,
Shashank