Answers.Body: <p>One option would be to do this with Drupal Views though I think you would end up needing to display a View within a View to deal with the multiple results you could have for both the OG memberships and the Civi Memberships. I did a quick proof of concept to check if all the joins were available which I attached to this <a href="http://www.fuzion.co.nz/blogs/view-display-contacts-civi-membership-and-og-membership" rel="nofollow">blog</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-22T17:59:15.590Z
Answers.Text: Hey Pete, I just wanted to come back and let you know that this is pretty much what we implemented - thank you. One question: when we created our view, we used "User" as the data, rather than CiviCRM Contacts - and then just set up a relationship to open up the CiviCRM fields. Do you think this was the wrong approach?
Answers.UserDisplayName: Alex Katayama
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-22T18:30:09.000Z
Answers.Text: Hi Alex. Hard to 'guess'. But yes I can see that you could start at either end of the daisy chain. I have often started at one end, and then if i hit any issues just reversed and built from the other end. Perhaps you could 'accept' this question and keep StackExchange happy
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-20T23:57:59.767Z
Answers.LastActivityDate: 2015-11-20T23:57:59.767Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>If you want to do this in code, you should be able to use the Drupal API to access all Drupal tables and fields in your code (<code>$result = db_query("SELECT nid, title FROM {node}")</code>;)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-21T08:15:35.167Z
Answers.LastActivityDate: 2015-12-21T08:15:35.167Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>We'd like to pass a Drupal field (Organic Group that a user belongs to) to a CiviCRM membership report. Has anyone done this and could give pointers or an example?</p>
  
Tags: <drupal><civireport><custom-reports>
Title: Passing a drupal field to civicrm report
ThreadText: # Passing a drupal field to civicrm report
  
  (Asked by: username_0 on 2015-11-20)
  
  We'd like to pass a Drupal field (Organic Group that a user belongs to) to a CiviCRM membership report. Has anyone done this and could give pointers or an example?
  
  **Tags:** drupal, civireport, custom-reports
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-11-20. Score: 2 | Accepted answer
  
  One option would be to do this with Drupal Views though I think you would end up needing to display a View within a View to deal with the multiple results you could have for both the OG memberships and the Civi Memberships. I did a quick proof of concept to check if all the joins were available which I attached to this [blog](http://www.fuzion.co.nz/blogs/view-display-contacts-civi-membership-and-og-membership).
  
  > **Comments:**
  > **username_0**: Hey Pete, I just wanted to come back and let you know that this is pretty much what we implemented - thank you. One question: when we created our view, we used "User" as the data, rather than CiviCRM Contacts - and then just set up a relationship to open up the CiviCRM fields. Do you think this was the wrong approach?  
  > **username_1**: Hi Alex. Hard to 'guess'. But yes I can see that you could start at either end of the daisy chain. I have often started at one end, and then if i hit any issues just reversed and built from the other end. Perhaps you could 'accept' this question and keep StackExchange happy  
  
  ---
  
  ### Answer by username_2 on 2015-12-21. Score: 1
  
  If you want to do this in code, you should be able to use the Drupal API to access all Drupal tables and fields in your code (`$result = db_query("SELECT nid, title FROM {node}")`;)
  
  
  ---
  
  