4

I am using civicrm_entity-7.x-2.x-dev to build a rule using Rules module. I want to use the action "CiviCRM Contact Send Email" to send an email to all members of a CiviCRM group.

So I need to loop over all of the contacts in a group and fire this action. The problem is that I don't see a way to provide a list of group-member contacts as a Rules loop.

I tried "Fetch CiviCRM entity by property" which can fetch a group using the Group ID. That works fine. However once this group entity is fetched, there is no variable like fetched_group:list-of-member-contacts - I only get a chain that leads to the contact who created the group or the contact who last updated the group. No "list of contacts in group"

Any pointers on sending CiviCRM mail with Rules to existing CiviCRM Groups/mailing lists?

  • I flicked a note on to Eileen in case she can comment – petednz - fuzion Apr 10 '15 at 22:49
6

You can use the Views Rules module: https://www.drupal.org/project/views_rules

This will provide a Views Loop: from the project page: "A view loop is similar to a regular Rules loop, but allows looping over rows of view results."

So enable that module, and then create a view that lists contacts that are in the group you desire.

Some basic instructions from the Views Rules project page:

Install the module (and make sure Rules UI and Views UI are both enabled)
Configured Views
    Add a view (with some fields)
    Add a "Rules" display
    Configure row variables
    Save
Configure Rules
    Add a rule
    Add the "Collect view result rows" action or add a view loop
    Select the "Rules" display
    Configure the parameters and variable names
    [Do what you want with the newly available variables]
  • This views rules module is incredible news to me! This will definitely do the trick. I will share here when I get a chance to try it. Thank you! – Link Swanson Apr 12 '15 at 20:18
  • Views Rules worked perfectly for this, thank you for turning me on to this! In the end I decided not to use the "CiviCRM Contact Send Email" action and instead wrote my own action that creates and schedules a CiviMail bulk mailing and accepts CiviCRM group IDs as parameters for the mailing recipients. github.com/LunkRat/civimail_tools – Link Swanson May 4 '15 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.