Filter leads emails with custom field (Enum)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WillRD
    Junior Member
    • Oct 2019
    • 9

    Filter leads emails with custom field (Enum)

    HI,

    I'm working on a BPM set on a custom target entity type.
    This custom entity has some leads attached to it.
    The BPM sends email to those leads. I have to select only some leads from those attached in the custom target entity (based on a enum field in the Leads entity)

    I don't manage to achieve... What would be the best way to do that process, please ?

    Thanks in advance.
  • yuri
    Member
    • Mar 2014
    • 8455

    #2
    Hi,

    It's tricky.

    Assuming you have the latest EspoCRM version (v5.9.2).

    1. Entity Manager: Create an additional relationship with leads, with a name, for example, 'leadsNew'.

    2. BPM flowchart: Then use formula function findRelatedMany https://docs.espocrm.com/administrat...indrelatedmany that will fetch all related lead ids that met the needed criteria.
    Code:
    $ids = record\findRelatedMany('YourEntityType', id, 'leads', 100, null, null, 'enumFieldName=', 'neededValue');
    3. BPM flowchart: Then use record\relate https://docs.espocrm.com/administrat.../#recordrelate to link these leads through 'leadsNew' relationship.
    Code:
    record\relate('YourEntityType', id, 'leadsNew', $ids);
    4. BPM flowchart: Then you will be able to use Send Message Task that will send email to all leads related through 'leadsNew' relationship.
    Last edited by yuri; 05-28-2020, 08:52 AM.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • WillRD
      Junior Member
      • Oct 2019
      • 9

      #3
      Thanx a lot YuriKuzn !

      I don't have the latest EspoCRM (v5.8.5)

      I'm going to try that anyway and keep you in touch

      Comment

      • yuri
        Member
        • Mar 2014
        • 8455

        #4
        These functions won't work on v5.8.5.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • WillRD
          Junior Member
          • Oct 2019
          • 9

          #5
          Ok thank you.
          I'm waiting for the admin to answer me about upgrading to the last version

          Comment

          • yuri
            Member
            • Mar 2014
            • 8455

            #6
            Note, that if you use Send Message Task in BPM and have multiple recipients, it will send a single email with multiple recipients in "TO" address.

            You can create Target List dynamically, populate it with recipients using formula, and then create MassEmail record with a created Target List.

            Or you can use formula to send multiple emails. In 5.9.3 version there will be 'while' function that will allow to loop through the list of IDs and send separate emails to each one. It's possible to send emails with formula.
            Last edited by yuri; 05-28-2020, 01:22 PM.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • esforim
              Active Community Member
              • Jan 2020
              • 2204

              #7
              Originally posted by WillRD
              Ok thank you.
              I'm waiting for the admin to answer me about upgrading to the last version
              You can manually upgrade it like me. First upgrade to 5.9.1 then manually patch those commit in your system.

              But you are waiting for "Admin", is that your internal admin or your server/host admin?

              Comment

              • WillRD
                Junior Member
                • Oct 2019
                • 9

                #8
                Originally posted by yurikuzn
                Note, that if you use Send Message Task in BPM and have multiple recipients, it will send a single email with multiple recipients in "TO" address.

                You can create Target List dynamically, populate it with recipients using formula, and then create MassEmail record with a created Target List.

                Or you can use formula to send multiple emails. In 5.9.3 version there will be 'while' function that will allow to loop through the list of IDs and send separate emails to each one. It's possible to send emails with formula.
                Yes It works fine Like that !
                Thanks a lot

                Comment

                • WillRD
                  Junior Member
                  • Oct 2019
                  • 9

                  #9
                  Originally posted by espcrm

                  You can manually upgrade it like me. First upgrade to 5.9.1 then manually patch those commit in your system.

                  But you are waiting for "Admin", is that your internal admin or your server/host admin?
                  Thank you for the tip.
                  I do have to refer to an internal administrator (CTO). I would have done it myself otherwise

                  Comment

                  • chinas
                    Junior Member
                    • Feb 2017
                    • 8

                    #10
                    Originally posted by yuri
                    Note, that if you use Send Message Task in BPM and have multiple recipients, it will send a single email with multiple recipients in "TO" address.

                    You can create Target List dynamically, populate it with recipients using formula, and then create MassEmail record with a created Target List.

                    Or you can use formula to send multiple emails. In 5.9.3 version there will be 'while' function that will allow to loop through the list of IDs and send separate emails to each one. It's possible to send emails with formula.
                    How can I loop through list of IDs (ver 5.9.4)?

                    Comment

                    Working...