Answers.Body: <p>If you are using Drupal then a View may be able to deliver you the required solution with less head aches.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-03T18:10:32.797Z
Answers.Text: I may end up going this route -- thanks for the suggestion. I was hoping to expand my toolset if possible, but sometimes requirements and available time foil my plan. :)
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-02T10:10:04.557Z
Answers.LastActivityDate: 2015-09-02T10:10:04.557Z
Answers.UserDisplayName: petednz - fuzion
Answers.Body: <p>When starting on reporting I did a lot of debugging in my report and in the parent class to find out what was happening.</p>
  
  <p>Your specific error: I strongly suspect <code>'relationship_type_c_civireport.label'</code> should be 'relationship_type_id_c....' but I am not sure.</p>
  
  <p>Check if there is a <em>postProcess</em> function in your class. If there is, it should call the parent <em>buildQuery</em> function to build the Query, you can check here how the query is build step by step. </p>
  
  <p>Also, the select part of the query is build in the select function from <code>$this-&gt;_columns</code>. If you debug the values of <code>$this-&gt;_columns</code> you should be able to find your problem. Happy hunting! And keep going, it is hard work at first but you will get there.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-03T18:09:45.953Z
Answers.Text: Thanks, I will keep plugging away -- I appreciate the pointers.
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-02T07:34:56.867Z
Answers.LastActivityDate: 2015-09-02T07:34:56.867Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I've used Civix to make a duplicate of the default Relationship report, and I'd like to extend it to show basic information for a third contact. So we have Contact A and can specify criteria about the relationship with Contact B, and now I'd also like to specify criteria about the relationship with Contact C, if there is such a contact.</p>
  
  <p>Civix helped generate a custom report extension and when I edit the PHP file, I can figure out how to duplicate some lines to produce the interface for the new columns and filters for Contact C. </p>
  
  <p><a href="https://i.sstatic.net/acdcv.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/acdcv.jpg" alt="New columns"></a></p>
  
  <p><a href="https://i.sstatic.net/MmdKh.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MmdKh.jpg" alt="New filters"></a></p>
  
  <p>The trouble I am having is in figuring how to properly name the duplicated array keys and variables so that I don't get "Unknown column" or similar SQL errors when I try to run it.</p>
  
  <p>The goal is to be able to end up with a simple list based on a primary contact, showing (for example) their spouse's name and their child's name (given a relationship of "Spouse of" and "Child of"). If they have no spouse/child relationships then those columns would be blank.</p>
  
  <p>Rather than hardcode SQL I would like to use the interface to allow selections of relationships for flexibility (and in case anyone else would have a use for it) but I am having a little difficulty as it is my first solid attempt to make a custom report with Civix.</p>
  
  <p>At the moment <a href="https://github.com/laryn/org.cedc.tripleplay/blob/master/tripleplay.php#L398-L400" rel="nofollow noreferrer">these particular lines of the extension</a> seem to be causing <code>** Unknown column 'relationship_type_c_civireport.label_a_c' in 'field list']</code> and <code>DB Error: no such field</code> errors. If anyone has a pointer, I would appreciate it!</p>
  
Tags: <extension><civireport><civix><custom-reports>
Title: How can I make a custom report that displays info for three contacts based on relationships?
ThreadText: # How can I make a custom report that displays info for three contacts based on relationships?
  
  (Asked by: username_0 on 2015-09-01)
  
  I've used Civix to make a duplicate of the default Relationship report, and I'd like to extend it to show basic information for a third contact. So we have Contact A and can specify criteria about the relationship with Contact B, and now I'd also like to specify criteria about the relationship with Contact C, if there is such a contact.
  
  Civix helped generate a custom report extension and when I edit the PHP file, I can figure out how to duplicate some lines to produce the interface for the new columns and filters for Contact C.
  
  [![New columns](https://i.sstatic.net/acdcv.jpg)](https://i.sstatic.net/acdcv.jpg)
  
  [![New filters](https://i.sstatic.net/MmdKh.jpg)](https://i.sstatic.net/MmdKh.jpg)
  
  The trouble I am having is in figuring how to properly name the duplicated array keys and variables so that I don't get "Unknown column" or similar SQL errors when I try to run it.
  
  The goal is to be able to end up with a simple list based on a primary contact, showing (for example) their spouse's name and their child's name (given a relationship of "Spouse of" and "Child of"). If they have no spouse/child relationships then those columns would be blank.
  
  Rather than hardcode SQL I would like to use the interface to allow selections of relationships for flexibility (and in case anyone else would have a use for it) but I am having a little difficulty as it is my first solid attempt to make a custom report with Civix.
  
  At the moment [these particular lines of the extension](https://github.com/laryn/org.cedc.tripleplay/blob/master/tripleplay.php#L398-L400) seem to be causing `** Unknown column 'relationship_type_c_civireport.label_a_c' in 'field list']` and `DB Error: no such field` errors. If anyone has a pointer, I would appreciate it!
  
  **Tags:** extension, civireport, civix, custom-reports
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-09-02. Score: 2
  
  If you are using Drupal then a View may be able to deliver you the required solution with less head aches.
  
  > **Comments:**
  > **username_0**: I may end up going this route -- thanks for the suggestion. I was hoping to expand my toolset if possible, but sometimes requirements and available time foil my plan. :)  
  
  ---
  
  ### Answer by username_2 on 2015-09-02. Score: 2
  
  When starting on reporting I did a lot of debugging in my report and in the parent class to find out what was happening.
  
  Your specific error: I strongly suspect `'relationship_type_c_civireport.label'` should be 'relationship\_type\_id\_c....' but I am not sure.
  
  Check if there is a *postProcess* function in your class. If there is, it should call the parent *buildQuery* function to build the Query, you can check here how the query is build step by step.
  
  Also, the select part of the query is build in the select function from `$this->_columns`. If you debug the values of `$this->_columns` you should be able to find your problem. Happy hunting! And keep going, it is hard work at first but you will get there.
  
  > **Comments:**
  > **username_0**: Thanks, I will keep plugging away -- I appreciate the pointers.  
  
  ---
  
  