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) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Boolean custom fields and filtration in Views 2
Pages: [1] 2

Author Topic: Boolean custom fields and filtration in Views 2  (Read 7274 times)

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Boolean custom fields and filtration in Views 2
March 07, 2009, 01:56:34 am
The current implementation of Views 2 integration does not allow to use custom fields - boolean variables as argument, filter or sort when creating a view.

Temporary workaround is to use Integer data type - selector - two values for custom field.

Later (when this will be fixed) it will be easy to transform this data back to logical by exporting and importing it as another custom field.

Regards,
Danila

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Boolean custom fields and filtration in Views 2
March 07, 2009, 08:06:58 am

i;m not sure i understand the problem. Can you try explaining it in more detail

also any chance you can provide a patch for the issue, since i suspect you know more about the views integration than we do :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 07, 2009, 08:37:31 am
This is an issue with custom field datatypes not getting correct handlers in civicrm.views.inc, in
Code: [Select]
function civicrm_views_custom_data_cache($data, $entity_type, $groupID, $subType, $style)
...
$data[$currentgroup['table_name']][$currentfield['column_name']] = array(
'title' => $currentfield['label'],
'help' => $currentfield['help_post'],
'field' => array(
  'handler' => civicrm_get_field_handler($currentfield['data_type']),
  'click sortable' => TRUE,
  ),

'argument' => array(
'handler' => civicrm_get_argument_handler($currentfield['data_type']),
),

'filter' => array(
   'handler' => civicrm_get_filter_handler($currentfield['data_type']),
   ),

'sort' => array(
'handler' => civicrm_get_sort_handler($currentfield['data_type']),
),
);

For example, if one has a custom boolean field for a contact, and wants to use this field as a filter in views (for example, showing in the view only people who had finished a particular educational program), Views 2 will throw error

Error: handler for civicrm_value_profile_name_3 > graduated__29 doesn't exist!

However, using integer custom fields in filters works - meaning some code for handler allocation is working correctly.

I have not yet found a way to set breakpoints in PHP to check what's going on inside the code (did not spend time to build PHP testing environment), so my previous updates were tested as a complete code without looking step-by-step inside.

I'm now importing data from old datasource - and I need to finish it so that users could start using new system for data entry. I make imports partially, by groups of fields, and check if I can build something useful using Views along the way. Currently only "Who works where" grouping works as I want.

After I finish Import I will work on presentation - and then I will need a lot of functionality from Views integration, which I will contribute back.

Regards,
Danila

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Boolean custom fields and filtration in Views 2
March 11, 2009, 06:27:22 pm
I set breakpoints in PHP with Netbeans 6.5 and the Xdebug module.  This works quite well with everything running on my laptop (Ubuntu 8.04).

-- Walt
http://dharmatech.org
oss@dharmatech.org
801.541.8671

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 14, 2009, 03:46:22 am
Thank you, Walt, I will check these tools.

Regards,
Danila

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 21, 2009, 08:22:03 pm
Boolean fields were recieving incorrect handlers in civicrm_get_*_handler(), except for civicrm_get_field handler.

Changed handlers as follows:

civicrm_get_argument_handler: was views_handler_argument_boolean, changed to views_handler_argument
civicrm_get_filter_handler: was views_handler_filter_boolean, changed to views_handler_filter_boolean_operator
civicrm_get_sort_handler: was views_handler_sort_boolean, changed to views_handler_sort

Patch in http://issues.civicrm.org/jira/browse/CRM-4275

Regards,
Danila

kdog98122

  • Guest
Re: Boolean custom fields and filtration in Views 2
March 28, 2009, 02:43:26 pm
I may be in the wrong place to ask this but I'm not a drupal or civicrm developer so if you can point me in the correct direction I would appreciate it.

Running drupal6.10 with Views6.x.2.3 and civicrm2.2.1.
DanilaD,

When trying to create a filter in a view of  civicrm contacts using a customer boolean field I get the same error as you describe:

Error: handler for civicrm_value_src_child_8 > publish_public_info_42 doesn't exist!

I applied your patch to civicrm.views.inc:

new:/home/flo-new/www/sites/all/modules/civicrm/drupal/modules/views $>diff civicrm.views.inc civicrm.views.inc.orig
2805c2805
<         return 'views_handler_argument_boolean';
---
>         return 'views_handler_argument';
2832c2832
<         return 'views_handler_filter_boolean';
---
>         return 'views_handler_filter_boolean_operator';
2859c2859
<         return 'views_handler_sort_boolean';
---
>         return 'views_handler_sort';



 but it did not fix the problem.

Any hints?

- Kevin


kdog98122

  • Guest
Re: Boolean custom fields and filtration in Views 2
March 28, 2009, 03:03:42 pm
To clarify, views allows me to use the custom boolean field as a field, but not as something to sort on or filter on.

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 28, 2009, 06:59:22 pm
Hello, kdog.

This means Views had not yet captured the change you made to code. Try going to Administer › Site building › Views › Tools and press "Clear Views cache".

Regards,
Danila


kdog98122

  • Guest
Re: Boolean custom fields and filtration in Views 2
March 30, 2009, 12:39:58 am
I cleared the views cache, the site wide drupal cache, restarted apache, and mysql and still get the same result.

I then tried creating a new view of type 'civicrm contact' and got the same error:

Filters Error: handler for civicrm_value_src_child_8 > publish_public_info_42 doesn't exist!

My next try would be to create a new group of custom fields for individuals with a boolean field and then a new drupal view.

This is on a development site so I can try anything you can suggest without impacting  our production site. 

Thank you for your time and help.  I feel I'm just a step away from getting into the drupal/civicrm code when I run into issues like this.

- Kevin


DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 30, 2009, 04:30:22 am
Could it be that you have old CiviCRM code in the modules folder? Not deleted from previous version?

Could you please check that you do not have a kind of backup copy that you created before applying patch? If present, it should be kept as far away from modules foles as possible.

kdog98122

  • Guest
Re: Boolean custom fields and filtration in Views 2
March 30, 2009, 08:57:08 am
 I deleted the entire civicrm directory before untarballing the 2.2.1 version.

I also verified that the pre-patched civicrm.views.inc was not anywhere in the root web directory or below. 

I did delete the backup that the patch created and then re-cleared the views cache, the drupal site cache, and restarted apache2 and mysql.

I've attached a screen shot of the custom field.  Is there anything special I have to do when setting up the field to get it the correct handler attached to it?

Is there anything else I can do to help?  Would a temporary login on the dev site help?

- Kevin


DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 30, 2009, 09:07:08 am
Could you please attach your civicrm.views.inc here?

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 30, 2009, 09:08:57 am
Also please check if you can use built-in boolean fields in filters, for example the "Do not email" field.

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Boolean custom fields and filtration in Views 2
March 30, 2009, 09:19:57 am
Hello, kdog.

I have just loaded CiviCRM install from Sourceforge, and it contains correct version of civicrm.views.inc. You do not need to apply patch to it, as this was a patch for 2.2.0, which is already included into 2.2.1.

I think applying this patch to 2.2.1 damages all thing. Please try to use the civicrm.views.inc supplied in civicrm-2.2.1-drupal.tar.gz.
Also, just clearing Views cache would be enough - Drupal cache and Apache server do not participate in Views regeneration.

Regards,
Danila

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Boolean custom fields and filtration in Views 2

This forum was archived on 2017-11-26.