CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Improving the way report filters are built from custom fields
Pages: [1]

Author Topic: Improving the way report filters are built from custom fields  (Read 1297 times)

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Improving the way report filters are built from custom fields
September 02, 2013, 12:01:46 pm
Hi All,

At the moment, there are some oddities in the way custom fields are presented in report filters.

1. Integer fields are always presented with the "OP_INT" operator, regardless of the input field type.  So, for example, if the custom field is an Integer Select such as [1: 'chocolate', 2: 'strawberry'], it's presented in the filters with operator choices like 'is less than', 'is greater than', etc.  Since users only ever see the labels 'chocolate' and 'strawberry', and they don't know the numerical values 1 and 2, this filter becomes hard for them to use.

2. If a custom field allows only one value to be chosen from a set of options (Radio, Boolean, single-select), the filter also allows only one option. The problem here is that when filtering, users often want to set the filter to include multiple values, just as they would on a multi-select field.  E.g., for a Radio field with options "Rock", "Paper", and "Scissors", the user may want to filter for "Rock and Paper". At the moment this is not possible.

I've got a patch for 4.2 which solves the above issues by 1) using the field's "input field type" (html_type) to determine the filter field operator, instead of using the field's data type; and 2) Crating multi-select filters for any custom field that offers a set of options.

If this is interesting, I'll be glad to port it to 4.3 and submit a patch.  Or if there are pitfalls I haven't considered, I'd love to hear about them.

Thanks!
- Allen
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Improving the way report filters are built from custom fields
September 02, 2013, 12:53:14 pm
I'm not an expert in reports, so take my comments with a grain of salt, but that sounds like an improvement to me.

Re: potential pitfalls -- When someone saves a report, it writes out the list of report fields/filters to disk. Would an old report (saved before the patches) still work with the new/patched report code?

TwoMice

  • I post frequently
  • ***
  • Posts: 214
  • Karma: 16
    • Emphanos
  • CiviCRM version: Always current stable version
  • CMS version: Drupal 7
Re: Improving the way report filters are built from custom fields
September 02, 2013, 02:10:08 pm
Yeah, good question, Tim. I think the difference would be in the operation field.  OP_INTEGER offers operators like 'is less than', while OP_MULTISELECT only offers "is one of" and "is not one of".  So if anyone had saved a report with filters set to "FieldX is-less-than 30", it would not work well to limit the possible operators to "is one of" and "is not one of".

Not sure what to do about that.  ???
Please consider contributing to help improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Improving the way report filters are built from custom fields

This forum was archived on 2017-11-26.