5

We have a set of custom data for memberships. One field is 'radio' type for newsletter delivery preference: online, paper, both, none. We can filter on this custom field in membership reports no problem, but cannot add it as a column in the report. I suspect this is an area related to custom report programming, and I'm not at all sure how to go about this. When I search on "custom field report column" I get a few hits in the forum that are a bit cryptic to me.

Update: To fix this all I had to do was upgrade to 4.6.2.

3

After reading your comments, I have a new answer. Please check the custom field in question and ensure that the "Searchable?" checkbox is checked.

Custom field screenshot

  • 1
    Perhaps there is a misunderstanding. The custom field has always been present and settable in the criteria sections, and is definitely searchable. The requirement is that the custom field appear in the display columns section and as a column in the final report. – P a u l May 5 '15 at 14:51
  • Hi Paul - the "Searchable" box controls whether custom fields show up in CiviReport - an undocumented but important fact! If you look at your custom field groups, what does the "Used For" for the custom field group in question say? That is, is this a custom field on the contact, the membership, or neither? If Contact, is it individual, organization, or all contacts? – Jon G - Megaphone Tech May 5 '15 at 17:24
  • Used For is "Membership". Searchable is checked. I can set a filter on this field no problem. As I said, the field is not in the Display Columns section which is what I need. I edited the title of this question. – P a u l May 5 '15 at 17:51
  • Paul - I think we're talking about the same thing, but it seems like you think otherwise. I took a screenshot to demonstrate what I think you're trying to do. Please take a look and see. If so - maybe see if your problem exists on the demo server as well? – Jon G - Megaphone Tech May 6 '15 at 4:17
  • Yours works, mine doesn't. It must be something in the way it is set up. I would need to have step by step instructions on how you did this test. – P a u l May 6 '15 at 17:32
2

You haven't specified which membership report you're referring to, so it's difficult to say for certain. However, the general approach should be:

  • Create a PHP override. There are many ways to do this, but the easiest would be to set a custom PHP path directory (Administer menu > System Settings > Directories).
  • Copy the PHP file that generates your report to the folder. E.g. if this is Membership Detail, copy <civicrmroot>/CRM/Report/Form/Member/Detail.php to <custom PHP folder>/CRM/Report/Form/Member/Detail.php.
  • At this point, I find I haven't quite done steps 1-2 correctly, so I edit the custom Detail.php to make sure my changes are reflected on the Membership Detail report. E.g. I go into the section called $this->_columns and change the title of a field, then reload the page to see that it worked.
  • Once you're convinced you have the override set up correctly, find the line that starts with: protected $_customGroupExtends. Add the entities that have the custom group in question to that line.
  • My custom Detail.php is working, but I don't know the syntax for adding custom data. My data is in Custom Data - Member Details - Newsletter Delivery Preference (radio type). I don't know what to put in $_customGroupExtends. Just adding 'Newsletter Delivery Preference' doesn't work. Also, do I need to create the column for this in the $this->_columns section? – P a u l May 4 '15 at 21:00
  • Don't know how to parse: "Add the entities that have the custom group in question to that line." The column I want to add is from a profile I created "Member Details" which uses custom data from a set I created "Member Details". I don't know what an "entity" is. Isn't the process more complicated; adding SQL select statements, etc.? – P a u l May 4 '15 at 23:02
  • Custom fields can be added with a lot less effort than non-custom fields - no need to create a column in $this->_columns. An "entity" maps roughly to a table in the database - so Contact, Membership, Contribution, etc. are all "entities". You can see a list of entities by visiting the API explorer (Help menu > Developer > API Explorer). However, now that I see that we're referring to the Member Detail report - the custom fields on Membership entities should already be added. I've created a new answer to address your situation. – Jon G - Megaphone Tech May 5 '15 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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