function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JaxBeachJaxBeach 

Can you restrict contacts email to case matches to a particular record type based on the email 2 case address?

Hi,  I intially posted this on the success site, but received a response that my question should probably be asked here.

We have 6 distinct companies in our salesforce org.  When an email to case comes in it looks for the email address on the incoming email and if it finds a match - it assigns it to that contact - at least that is what I assume it does.  Anyway,  We run into permission errors because company A has a case where the contact is really in company B.  Is there a way to restrict what contact email addresses it looks for coming in?  If so, would that be an APEX code thing or is that like API stuff our IT department could do?  Hope this makes sense.  thanks.
HARSHIL U PARIKHHARSHIL U PARIKH
It looks right now when the email address comes with the case, the existing code searches through the entire database of Contact regardless of which contact from which company.
What you need to do is when the EmailToCase comes means whenever the email address comes in, identify which company's contacts records it needs to search in and then put the search on them.

E.g., Let's say coming email is John@gmail.com right?!  Now identify the particular company's contacts which needed to be search or in other words which needed to be compared one by one to this John@gmail.com email until it finds it the match.

In addition, I would say based on my knowledge and experience one salesforce instance is should be for the one company though because this is just the begining but going further you may encounter lots of and lots of scenarios like these where you would realize you could have been better off keeping one instance for one company.