Announcement

Collapse
No announcement yet.

Link email to opportunity automatically

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Link email to opportunity automatically

    What do I need to add to the email subject or body to link it to the opportunity? I tryed to add id to subject and body. It does not work.

    Doc quote - "When the new email comes the system tries to recognize which record this email belongs to. It can link it with Account, Lead, Opportunity, Case (and Contact in B2C mode) etc."

  • #2
    Hi romach,

    If I understand you correctly, you need to use the Opportunity ID as the Parent ID for the email.
    You can use these formulas:

    entity\setAttribute('parentId', $opportunityId);
    OR
    record\update('Email', $emailId, 'parentId', $opportunityId);

    Please describe what kind of functionality you need (after which action you need to link Opportunity and Email, for example), so that I can help you more extensively.
    Last edited by lazovic; 07-01-2022, 06:55 AM.

    Comment


    • #3
      Originally posted by lazovic View Post
      Hi romach,

      Please describe what kind of functionality you need (after which action you need to link Opportunity and Email, for example), so that I can help you more extensively.
      I want to set ParentId to OpportunityId automatically when new email is received. I don't understand how it works in Espoo. An easy way is to add the OppId to the subject or message body.

      Comment


      • #4
        it is difficult to do it, requires a lot of coding and will cause issues. once an email is received the crm will map it to the correct parent, e.g email received for an account then parentId will be accountId hence account has an email field. i think one way to do it is to add an email field on your opportunity entity and once an email is received it will be mapped and linked with opportunity as its parent entity.

        hope this helps.

        Comment


        • #5
          Workflow can help. There is simple formula script to assign parent opportunity to email by embraced opportunity number, for example {{ON12345}}:
          PHP Code:
          $pn string\match(body,'/{{\s*ON[^}]*}}/');
          ifThen($pn == null,
              
          $pn string\match(bodyPlain,'/{{\s*ON[^}]*}}/');
              
          ifThen($pn != null,
                  
          $opportunityId record\findOne('Opportunity'nullnull'number='string\trim(string\replace(string\replace($pn,'{'''),'}','')));
                  
          ifThen($opportunityId != null,
                      
          entity\setAttribute('parentId'$opportunityId);
                      
          entity\setAttribute('parentType''Opportunity');
                  );
          ); 
          ‚Äč

          Comment

          Working...
          X