Answers.Body: <p>I've run into an almost identical problem, which I solved with a custom extension.  I've hardcoded which groups correspond to chapters, and whenever someone is added to a group, I check if it's a "chapter" group.  If so, I update a custom field with their chapter name, so I can export it.
  I could upload the entire extension to Github if you like, but the relevant code is here.</p>
  
  <p><code>
  function membershipcards_civicrm_post($op, $objectName, $objectId, &amp;$objectRef) {
    //set the chapter name for membership cards
    if(($op == 'create' || $op == 'edit') &amp;&amp; $objectName == 'GroupContact'){
      $params = array(
        'version' =&gt; 3,
        'sequential' =&gt; 1,
        'contact_id' =&gt; $objectRef[0],
      );
      $result = civicrm_api('GroupContact', 'get', $params);
      //cycle through the groups.  If you find one that's a chapter
      //(currently hardcoded as gid &lt;= 83), return its title.
      foreach($result['values'] as $key =&gt; $value){
        if($value['group_id'] &lt;= 83) {
          $chapter = $value['title'];
          break;
        }
      }
      $params = array(
        'version' =&gt; 3,
        'sequential' =&gt; 1,
        'custom_98' =&gt; $chapter,
        'id' =&gt; $objectRef[0],
      );
      $result = civicrm_api('Contact', 'create', $params);
    }
  }
  </code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-27T16:43:25.053Z
Answers.Text: Hi Jon, I think your approach may be the best way to go about it. I'll have to think about it a little more in detail but it sounds like a good approach. There are some edge cases whereindividuals belongs to more than one region (that doesn't make sense but it happens). Overall I think this will at least take care of the lion's share of the export.
Answers.UserDisplayName: Andrew Wasson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-26T02:06:23.477Z
Answers.LastActivityDate: 2015-03-26T05:47:56.190Z
Answers.LastEditDate: 2015-03-26T05:47:56.190Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Groups is not available as a field when using the Member export.  Note that it is available when using the contact export in case that is of any help but I guess not since given you are trying to do renewals via CSV you probably want to see membership fields in the export.</p>
  
  <p>One 'lowtech' solution would be to do two exports - one of your membership data and one with contact data (potentially filtered to members) and then  use a tool that can merge these two data sources.  Pretty sure that Excel's vlookup function can handle that kind of thing quite easily but I don't really use it much.</p>
  
  <p>Else you could commission someone (the core team for instance) to get the group field export added to the membership export.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T23:13:21.923Z
Answers.Text: Thanks Michael. The lowtech method is what I've been doing up until now but a single export without VLOOKUP would be preferable.
Answers.UserDisplayName: Andrew Wasson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-25T22:35:40.497Z
Answers.LastActivityDate: 2015-03-25T22:35:40.497Z
Answers.UserDisplayName: michaelmcandrew
Body: <p>I'm managing a country-wide organization's membership database with 1 membership type (you're either a member or you're not). Each region or province/state is represented by a Group. </p>
  
  <p>This allows us to create an online roster (membership listing) that can be filtered by the regions across the country. </p>
  
  <p>All of the updates to contact records and membership records (renewals) are handled via CSV imports.</p>
  
  <p>For improving the maintenance of the CRM information, my goal is to run a search memberships report for current/new members which I can then split by region. I can then send the exec-admins governing each region their piece of the report so they will have a unified spreadsheet for managing addition and updates to the members they govern, making imports smoother to update contact records and membership renewals. </p>
  
  <p>The issue I am running into is exporting a membership CSV spreadsheet that includes the all important Group or Group ID number. Any thoughts?</p>
  
Tags: <workflow>
Title: Can we export from membership search and include fields for groups?
ThreadText: # Can we export from membership search and include fields for groups?
  
  (Asked by: username_0 on 2015-03-25)
  
  I'm managing a country-wide organization's membership database with 1 membership type (you're either a member or you're not). Each region or province/state is represented by a Group.
  
  This allows us to create an online roster (membership listing) that can be filtered by the regions across the country.
  
  All of the updates to contact records and membership records (renewals) are handled via CSV imports.
  
  For improving the maintenance of the CRM information, my goal is to run a search memberships report for current/new members which I can then split by region. I can then send the exec-admins governing each region their piece of the report so they will have a unified spreadsheet for managing addition and updates to the members they govern, making imports smoother to update contact records and membership renewals.
  
  The issue I am running into is exporting a membership CSV spreadsheet that includes the all important Group or Group ID number. Any thoughts?
  
  **Tags:** workflow
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-03-26. Score: 3
  
  I've run into an almost identical problem, which I solved with a custom extension. I've hardcoded which groups correspond to chapters, and whenever someone is added to a group, I check if it's a "chapter" group. If so, I update a custom field with their chapter name, so I can export it.
  I could upload the entire extension to Github if you like, but the relevant code is here.
  
  `function membershipcards_civicrm_post($op, $objectName, $objectId, &$objectRef) {
  //set the chapter name for membership cards
  if(($op == 'create' || $op == 'edit') && $objectName == 'GroupContact'){
  $params = array(
  'version' => 3,
  'sequential' => 1,
  'contact_id' => $objectRef[0],
  );
  $result = civicrm_api('GroupContact', 'get', $params);
  //cycle through the groups. If you find one that's a chapter
  //(currently hardcoded as gid <= 83), return its title.
  foreach($result['values'] as $key => $value){
  if($value['group_id'] <= 83) {
  $chapter = $value['title'];
  break;
  }
  }
  $params = array(
  'version' => 3,
  'sequential' => 1,
  'custom_98' => $chapter,
  'id' => $objectRef[0],
  );
  $result = civicrm_api('Contact', 'create', $params);
  }
  }`
  
  > **Comments:**
  > **username_0**: Hi Jon, I think your approach may be the best way to go about it. I'll have to think about it a little more in detail but it sounds like a good approach. There are some edge cases whereindividuals belongs to more than one region (that doesn't make sense but it happens). Overall I think this will at least take care of the lion's share of the export.  
  
  ---
  
  ### Answer by username_2 on 2015-03-25. Score: 1
  
  Groups is not available as a field when using the Member export. Note that it is available when using the contact export in case that is of any help but I guess not since given you are trying to do renewals via CSV you probably want to see membership fields in the export.
  
  One 'lowtech' solution would be to do two exports - one of your membership data and one with contact data (potentially filtered to members) and then use a tool that can merge these two data sources. Pretty sure that Excel's vlookup function can handle that kind of thing quite easily but I don't really use it much.
  
  Else you could commission someone (the core team for instance) to get the group field export added to the membership export.
  
  > **Comments:**
  > **username_0**: Thanks Michael. The lowtech method is what I've been doing up until now but a single export without VLOOKUP would be preferable.  
  
  ---
  
  