You need to sign in to do that
Don't have an account?
Victoria Winters
Trigger to truncate email header for email-to-case
We have encountered an issue with some cases coming in through email-to-case that bouce back becasue the string is too long and exceeds the 32,000 character limit. Support says this is hard coded and cannot increase the limit. The issue is the header that Microsoft is appending to the emails as pushing it over the limit and IT has spoken with them and this also cannot be adjusted. The recommendation from support is to write a trigger to truncate the email header. Since I am not a developer I don't know how to write this trigger. Curious if anyone else has done something like this already. I have looked through the community and can't find much info on this. Any guidance would be much appreciated!
All Answers
trigger CaseTruncateSubject on Case (before insert) {
For(Case c :Trigger.New){
If(c.Subject!=null){
Integer MySubjectLength = c.Subject.Length();
If(MySubjectLength > 255){
c.Subject = c.Subject.substring(0,255);
}
}
}
}
5. Navigate to FileàNewà Apex Class
6. Enter this info:
1. Name: CaseTruncateSubject_TEST
2. Paste the below code in and click save
@IsTest
public class CaseTruncateSubject_TEST {
static testMethod void Truncate() {
Case c=new Case(Description='1',Subject='1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111');
insert c;
}
}
7. Test the email to case using a subject longer than 255 characters