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

How can i prevent to create Duplicate case record in Email-to-case
Hi All,
I am new to Salesforce .
I have configured Email-to-Case in my org.its working fine but
when i used to send a mail to my configured mail-id a case record is getting created.
when i am sending second mail i didn't want to create case record with my second mail.
Simply i want to attached the mail to my previous record.
I have written below code:
trigger UpdateCaseTrigger on Case (before insert) {
if( Trigger.isBefore){
List<Case> cs1=[select id,Status,SuppliedEmail,Subject,Description,Origin from Case];
List<EmailMessage> em1=new List<EmailMessage>();
for(case cs:Trigger.New){
for(case cs2:cs1){
if(cs.SuppliedEmail==cs2.SuppliedEmail && cs2.Status=='New'){
EmailMessage em=new EmailMessage();
em.RelatedToId=cs.Id;
em.Subject=cs.Subject;
em1.Add(em);
}
}
}
insert em1;
}
}
what can i do , please suggest any Solution.
I am new to Salesforce .
I have configured Email-to-Case in my org.its working fine but
when i used to send a mail to my configured mail-id a case record is getting created.
when i am sending second mail i didn't want to create case record with my second mail.
Simply i want to attached the mail to my previous record.
I have written below code:
trigger UpdateCaseTrigger on Case (before insert) {
if( Trigger.isBefore){
List<Case> cs1=[select id,Status,SuppliedEmail,Subject,Description,Origin from Case];
List<EmailMessage> em1=new List<EmailMessage>();
for(case cs:Trigger.New){
for(case cs2:cs1){
if(cs.SuppliedEmail==cs2.SuppliedEmail && cs2.Status=='New'){
EmailMessage em=new EmailMessage();
em.RelatedToId=cs.Id;
em.Subject=cs.Subject;
em1.Add(em);
}
}
}
insert em1;
}
}
what can i do , please suggest any Solution.
Are you sending your emails to the "email service address"?
Related: https://help.salesforce.com/s/articleView?id=000315574&type=1
https:/ideas.salesforce.com/s/idea/a0B8W00000GdpfvUAB/duplicate-management-for-cases
Yes, I am sending emails to "Email Service Addess".
Do you have thread id's in email's. If thread id is there then Salesforce automatically map the emails under original case. If you don't want to use the thread id concept then write the custom code to delete the duplidate case and the append the email message under existing one.
https://www.emizentech.com/blog/new-threading-behavior-in-email-to-case.html
https://automationchampion.com/2022/03/30/update-the-case-status-through-email-to-case-response-2/
https://help.salesforce.com/s/articleView?id=sf.support_email_to_case_threading.htm&type=5
Please go throw the slide in the below to learn complete salesforce email to case.
https://www.asagarwal.com/a-step-by-step-guide-to-setting-up-email-to-case-in-salesforce/
Thanks,
Maharajan.C
1. Customer emailed Sales Tech directly. They go back and forth on email.
2. At some point our support email address is added to the cc field.FaceTime (https://www.facetimeapps.org/)
3. Everytime they reply all a new case is added.
I know this is because the thread ID is missing. Technically Sales Tech should wait for the email that a new case is received (which includes the Thread ID) and reply all to that (since it includes the contact)... then if they go back and forth on that it will track to one case.
Is there anything else that can be done/put in place in these cases? We don't have them often - but when they occur they are a pain.
can you suggest me or give me some hint how can i write Custom code, if you have any example.
Thanks
Jai