Answers.Body: <p>Sorry I don't have a solution in CiviCRM directly. if you are using Drupal, then I would expect that you can make a View that uses Aggregation that should give you the count of relationshipss along with address etc which you could then print out as Mailing Labels either via a PDF plugin for Views, or view an external 'mail merge' solution.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-21T02:12:51.417Z
Answers.LastActivityDate: 2015-09-21T02:12:51.417Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>Pete's answer is the only solution I can think of that doesn't require coding, but it's only an option for Drupal users.</p>
  
  <p>If you're on Joomla/Wordpress, you'll need to code a solution, or hire someone to do so.  Create a custom field on the contact "number of relationships".  Create an extension with <code>civix</code> and use <code>hook_civicrm_post</code> on any relationship being created/updated/deleted; use an API call to <code>getcount</code> for relationships, and populate the number of relationships to your custom field.</p>
  
  <p>If you know SQL but not PHP, an easier solution is to set up a cron job to fill in the custom field with a SQL statement that runs over the whole database.  I'm not sure if you can use an UPDATE statement with a GROUP BY though - so you might need to use a subselect, which is expensive.</p>
  
  <p>The other SQL-centric option is to create a trigger to handle this.  You can be quick and dirty and drop it right into the database, or you can wrap it in a CiviCRM extension.  If you go the latter route, consider coding it into the "Summary Fields" extension: <a href="https://civicrm.org/extensions/summary-fields" rel="nofollow">https://civicrm.org/extensions/summary-fields</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-21T03:06:00.937Z
Answers.LastActivityDate: 2015-09-21T03:06:00.937Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I need to mail multiple copies of our Client and Family Newsletter to households shared by individual clients. </p>
  
  <p>How can I access the 'number of relationships' for each household (visible in the top ribbon), so that I could include that number in the info I give to the mail house, so that they can put the right number of copies in the envelope for each household? </p>
  
  <p>Or is there a better way to achieve the same outcome?</p>
  
Tags: <contacts>
Title: How can I include the number of relationships in a household in exported data for that household
ThreadText: # How can I include the number of relationships in a household in exported data for that household
  
  (Asked by: username_0 on 2015-09-21)
  
  I need to mail multiple copies of our Client and Family Newsletter to households shared by individual clients.
  
  How can I access the 'number of relationships' for each household (visible in the top ribbon), so that I could include that number in the info I give to the mail house, so that they can put the right number of copies in the envelope for each household?
  
  Or is there a better way to achieve the same outcome?
  
  **Tags:** contacts
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-09-21. Score: 4 | Accepted answer
  
  Pete's answer is the only solution I can think of that doesn't require coding, but it's only an option for Drupal users.
  
  If you're on Joomla/Wordpress, you'll need to code a solution, or hire someone to do so. Create a custom field on the contact "number of relationships". Create an extension with `civix` and use `hook_civicrm_post` on any relationship being created/updated/deleted; use an API call to `getcount` for relationships, and populate the number of relationships to your custom field.
  
  If you know SQL but not PHP, an easier solution is to set up a cron job to fill in the custom field with a SQL statement that runs over the whole database. I'm not sure if you can use an UPDATE statement with a GROUP BY though - so you might need to use a subselect, which is expensive.
  
  The other SQL-centric option is to create a trigger to handle this. You can be quick and dirty and drop it right into the database, or you can wrap it in a CiviCRM extension. If you go the latter route, consider coding it into the "Summary Fields" extension: <https://civicrm.org/extensions/summary-fields>
  
  
  ---
  
  ### Answer by username_1 on 2015-09-21. Score: 2
  
  Sorry I don't have a solution in CiviCRM directly. if you are using Drupal, then I would expect that you can make a View that uses Aggregation that should give you the count of relationshipss along with address etc which you could then print out as Mailing Labels either via a PDF plugin for Views, or view an external 'mail merge' solution.
  
  
  ---
  
  