On case creation from an email2case process, the case description gets populated with a text version of the email.
In the scenario of when the inbound email email is large, I was expecting the text to be truncated to 32000 characters to fit in the case description field.
What I am observing instead is the case description length is larger than 32000 by a small amount (ie. btw 1-2000 over limit). This means when an agent tries to make changes to the case and hits save, it shows them an error message "Error: Invalid Data", forcing them to truncate the description field themselves.
I have tried truncating the description field in a before insert/update trigger
for (Case c : (Case[]) Trigger.new) { String d = c.description; if (!string.isBlank(d) && d.length() >= 32000) { c.description = d.substring(0, 32000); } } but the if condition never appears to be true, even if the description data is longer than 32000 characters.
What options do I have to fix this?
\rbut I may be wrong). Hence, the save fails