No announcement yet.

Email to Case for Contacts Only

  • Filter
  • Time
  • Show
Clear All
new posts

  • Email to Case for Contacts Only

    Is it possible to restrict the email to case feature to only create a case for contacts that already exist in the system.

    For example:
    John Smith is a contact with email John uses this address to email A case is created.

    Jane Doe is not a contact and has no emails in the system. Jane sends an email to A case is not created.

    Is this functionality possible?

  • #2

    here you have the function but I don’t know if you can have in upgrade save


    • #3
      Thank you for this. I’ll review the code and post any questions I have here in this thread.


      • #4
        From reading this code, it appears that if a contact cannot be located, then the system falls back to the account and looks for a lead with that email address. If no lead is found, it just creates the case with no contact/lead records. Am I reading this correctly? Is there a way to add a checkbox to a Group Email Account to enforce this rule? If someone could show me how to create such an option, I'd be happy to PR it as time allows.


        • #5
          in the past i have searched for something like your request, and in many place "Account, Contact, Lead" it's hard coded.
          i am not a "good developper" .. but i think it's the way.

          All below is sample, you can adapt name or ..

          1) create a multi-enum Field : createCaseForEntity : ["Account", "Contact", "Lead"] like caseDistribution

          2) make it visible on the layout, just like caseDistribution

          3) adapt view detail in some place like

          At this moment, if you can see the new field/hide/show and save correctly in database it's good i think

          Now we need to adapt the function :

          PHP Code:
          if (!empty($params['createCaseForEntity'])) {   $createCaseForEntity $params['createCaseForEntity'];   }   // multi-enum, certainly need to cast in array..

          // and the logic for all

          foreach( $createCaseForEntity as $entityType ){  
          $foundEntity $this->entityManager->getRDBRepository$entityType )   ->join('emailAddresses''emailAddressesMultiple')   ->where([   '' => $email->get('fromEmailAddressId'),   ])   ->findOne();      

            if (
          $foundEntity) {  
          $case->setlowerCase$entityType ).'Id'  $foundEntity->getId());  

          $email->set('parentType'CaseObj::ENTITY_TYPE);   $email->set('parentId'$case->getId());


          edit : maybe need order entityType, so if first if find, break the loop.. need add custom person entity in this..
          Last edited by item; 11-28-2022, 12:51 AM.


          • #6
            Thank you! I will research this in the morning and see what I can come up with. If I can get this to work as expected and within the code standards, I'll submit a PR.


            • #7
              i have tested, point 1, 2, 3 .. it's ok .. i have field and save in database.
              maybe, we can do 1, 2, 3 upgrade save. .. certainly.

              after problem begin (my skill) .. how use/override the function "createCase".

              Then one more think : feature request :

              we have, account, person, event, ... why not have a entity template "Case" ...
              so imagine :
              support@xyz => create "Case like Support entity"
              info@xyz => create "Case like Info entity"

              So in GroupEmailAccount, we need select witch EntityType .. and For witch related (not only contact or lead, but other custom entity)

              it's doable for me