2

I'm confused why Organization Name and Prefix are in the Lybunt report but not in the Sybunt report. They both have

'fields' => $this->getBasicContactFields(),

which I thought included these fields. Maybe I'm missing something.

I can quickly add Organization with this:

'organization_name' => array(
            'title' => ts('Organization'),
          ),

but I'm unclear how to add the prefix_id and convert it to the correct output (Mr., Mrs., etc)

   'prefix_id' => array(
            'title' => ts('Prefix'),

Thanks in advance for your help.

Drupal 7.51, Civicrm 4.7.11

1 Answer 1

2

Agreed that the correct solution is to work within getBasicContactFields(), but since your question is a good one with a more general application:

When you add organization name and prefix, you're doing so by adding them to the class's _columns property. As you note, this doesn't look up "pseudoconstants", such as converting prefix_id to a prefix.

That happens in the alterDisplay method toward the bottom of the same file. Here's a good example in the Lybunt report of using a pseudoconstant lookup to convert the gender ID to a gender:

https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form/Contribute/Lybunt.php#L719

Hopefully this example is what you need; otherwise feel free to comment/update the question!

1
  • Thanks Jon! That worked perfectly and is going to help so much moving forward in trying to build out custom reports.
    – jansmath3
    Oct 25, 2016 at 18:32

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.