Answers.Body: <p>You can use the Views Rules module: <a href="https://www.drupal.org/project/views_rules">https://www.drupal.org/project/views_rules</a></p>
  
  <p>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."</p>
  
  <p>So enable that module, and then create a view that lists contacts that are in the group you desire.  </p>
  
  <p>Some basic instructions from the Views Rules project page:</p>
  
  <pre><code>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]
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-12T20:18:18.483Z
Answers.Text: 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!
Answers.UserDisplayName: LunkRat
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-04T17:32:14.087Z
Answers.Text: 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. https://github.com/LunkRat/civimail_tools
Answers.UserDisplayName: LunkRat
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-12T20:12:36.947Z
Answers.LastActivityDate: 2015-04-12T20:12:36.947Z
Answers.UserDisplayName: jackrabbithanna
Body: <p>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. </p>
  
  <p>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.</p>
  
  <p>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 <code>fetched_group:list-of-member-contacts</code> - 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"</p>
  
  <p>Any pointers on sending CiviCRM mail with Rules to existing CiviCRM Groups/mailing lists?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-10T22:49:51.117Z
Comments.Text: I flicked a note on to Eileen in case she can comment
Comments.UserDisplayName: petednz - fuzion
Tags: <drupal><civicrm-entity><drupal-rules>
Title: Drupal CiviCRM Entity in Rules: How to loop over all members of a group?
ThreadText: # Drupal CiviCRM Entity in Rules: How to loop over all members of a group?
  
  (Asked by: username_0 on 2015-04-10)
  
  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?
  
  **Tags:** drupal, civicrm-entity, drupal-rules
  
  > **Comments:**
  > **username_1**: I flicked a note on to Eileen in case she can comment  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-04-12. Score: 6 | Accepted answer
  
  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]
  
  > **Comments:**
  > **username_0**: 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!  
  > **username_0**: 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. https://github.com/username_0/civimail_tools  
  
  ---
  
  