Announcement

Collapse
No announcement yet.

Create Opportunity from email - problem with field 'Contact'

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

  • Create Opportunity from email - problem with field 'Contact'

    Hello,
    I would like to create Opportunity when I get new email on specified email adress.
    I relete Many-to-Many email with Contact and create attached workflow for email (after create).
    Name, Account, Description are coppied correctly. I habe problem with field Contact. Why Contact form email can't be coppied to Conntact in Opportunity? It is bug?
    Thank you for any help.


  • #2
    Hello,
    I think it's not a bug. There's a hard logic behind the scene.
    Try to use Formula here to fetch a Contact ID and then add it to the Contacts link-multiple field.
    - To get users ID try to use the 'record\findOne' function https://docs.espocrm.com/administrat...#recordfindone
    - To add the fetched contact ID to the Contacts field try to use the entity\addLinkMultipleId function https://docs.espocrm.com/administrat...linkmultipleid.



    Comment


    • #3
      Originally posted by Maximus View Post
      Hello,
      I think it's not a bug. There's a hard logic behind the scene.
      Try to use Formula here to fetch a Contact ID and then add it to the Contacts link-multiple field.
      - To get users ID try to use the 'record\findOne' function https://docs.espocrm.com/administrat...#recordfindone
      - To add the fetched contact ID to the Contacts field try to use the entity\addLinkMultipleId function https://docs.espocrm.com/administrat...linkmultipleid.


      Thank you Maximus for the answer. Could you give more information on how to use the record \ findOne function to capture ContactID from email?

      PHP Code:
      $ids record\findOne(???)
      entity\addLinkMultipleId('Contact'$ids); 

      Comment


      • #4
        Hi,
        Should be something like this:
        PHP Code:
        $ids record\findOne('Contact''createdAt''desc''emailAddress='targetEntity\attribute('from'));
        entity\addLinkMultipleId('contact'$ids); 
        targetEntity\attribute() - formula to retrieve attribute from the target entity of Workflow. In your case it is Email.

        'from' - field that should contain a 'From' email address. If it won't work you can try 'fromAddress' instead.

        entity\addLinkMultipleId('contact', $ids); - link name should starts from lowercase.

        Comment


        • #5
          Something's still wrong, Contacts are still not linked to Opportuity. My workflow looks like attached. What I doing wrong?

          Comment


          • #6
            Hi,
            I've debugged it and found the issue.
            The link-multiple name to Contact entity is 'contacts'. Please change entity\addLinkMultipleId('contact', $ids); toentity\addLinkMultipleId('contacts', $ids);
            Last edited by Maximus; 03-29-2021, 04:42 PM.

            Comment


            • LuckyLouie
              LuckyLouie commented
              Editing a comment
              Now It works! Thank You for help Maximus!
          Working...
          X