You need to sign in to do that
Don't have an account?
Swetha B 7
Case Description parsing logic help
I have an Email to Case set up. Details coming into the body of the email. Need to Parse that Case Description Info into fields in Case.
Email to the case is set up. The detail comes into the description:
Contact Form
A user submitted the following information on the Contact us page
Name: XXXX
Phone: XXXX
Email: XXXX
Question/Comments:
I have fields for each option and I need to pass the information into those fields. the format is the same every time.
Please correct the trigger logic or provide me the solution for it.
trigger parsingemail on Case (before insert) {
for(Case C:trigger.new){
if(C.Subject!=Null && C.Subject.Contains('Contact Form')==True){
if(C.Description!='' && C.Description.length()>0){
String data=C.Description;
C.SuppliedName=data.substringBetween('Name:', 'Phone:');
C.SuppliedPhone=data.substringBetween('Phone:', 'Email:');
C.SuppliedEmail=data.substringBetween('Email:', 'Question / Comment:');
update C;
}
}
}
}
Email to the case is set up. The detail comes into the description:
Contact Form
A user submitted the following information on the Contact us page
Name: XXXX
Phone: XXXX
Email: XXXX
Question/Comments:
I have fields for each option and I need to pass the information into those fields. the format is the same every time.
Please correct the trigger logic or provide me the solution for it.
trigger parsingemail on Case (before insert) {
for(Case C:trigger.new){
if(C.Subject!=Null && C.Subject.Contains('Contact Form')==True){
if(C.Description!='' && C.Description.length()>0){
String data=C.Description;
C.SuppliedName=data.substringBetween('Name:', 'Phone:');
C.SuppliedPhone=data.substringBetween('Phone:', 'Email:');
C.SuppliedEmail=data.substringBetween('Email:', 'Question / Comment:');
update C;
}
}
}
}
In stead of description in the third line of the code change the field to subject as below.
Thanks
All Answers
As per above you are sending the Contact Form as the description but not as the subject. so we need to check the contains for the description instead of the subject.
Secondly as we are doing the before context in the trigger no need to mention the DML operation i'e Update. Please find the below piece of code.
If this solution helps, please mark it as best answer.
Thanks
The subject is coming as a "Contact Form" always and on the case description coming email body with the following format like line space between each field.
Contact Form
A user submitted the following information on the Contact us page
Name: XXXX
Phone: XXXX
Email: XXXX
Question/Comments:
Please suggest
In stead of description in the third line of the code change the field to subject as below.
Thanks