1

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

New filters

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 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!

2 Answers 2

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.

1
  • Thanks, I will keep plugging away -- I appreciate the pointers.
    – Laryn
    Sep 3, 2015 at 18:09
2

If you are using Drupal then a View may be able to deliver you the required solution with less head aches.

1
  • 1
    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. :)
    – Laryn
    Sep 3, 2015 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.