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) »
  • Views, Activities and Custom Fields
Pages: [1]

Author Topic: Views, Activities and Custom Fields  (Read 4397 times)

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Views, Activities and Custom Fields
March 17, 2009, 03:49:26 am
Using CiviCRM 2.2 Stable, Drupal 6.10 and the current version of views2

I am working on producing views of activity data. I have created activity types that have custom fields and wish to produce an online 'report' using views 2

I have copied all table prefixes listed in the drupal integration settings to the settings.php - this includes the custom field groups.

My Drupal database user has select rights on the CiviCRM database, which is a separate database

I am able to create views using standard activity fields, but I have no visibility of custom fields associated with activities.

If I start with contacts (when creating the view) I have all the custom fields for contacts, but if I start with activities then I do not have custom fields created for activities.

The same situation applies to Relationships (I just happen to have a couple of custom data fields extending this entity type as well)

I note that the joins are set up in function civicrm_views_custom_data_cache of views.inc - I can't see anything glaringly obvious and I don't have anything to step through the code and debug that way.
« Last Edit: March 17, 2009, 05:38:40 am by myles »

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: Views, Activities and Custom Fields
March 17, 2009, 09:35:26 am

1. you might want to turn off views caching (for debugging purposes)

2. You might want to add debug statements to civicrm_views_custom_data_cache and see what data and tables are exposed by the civicrm views integration code to the views2 engine. That might give you a few clues as to why / what is not working

if you do find and solve the bug, please file an issue along with your patch

thanx

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

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Views, Activities and Custom Fields
March 17, 2009, 03:45:14 pm
My first priority has to be to keep the day job going and that means re-implementing the process to enter data into custom fields in the contact record so that I can report it.

Next I'll start to debug - the only problem being that I have no idea what I'm doing - well not exactly true, but I am new to php, so don't hold your breath!
« Last Edit: March 18, 2009, 12:33:54 am by myles »

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Views, Activities and Custom Fields
March 18, 2009, 06:06:46 am
I'm sorry - I'm way over my head - do you have any examples or articles on debugging this kind of module?

In principle I can get eclipse set up to debug php script setting debug break points and examining variables - but that's for a php script that i can get a handle on - I'm finding it difficult to get to grips with Drupal / CiviCRM sufficiently to know how to start debugging a script that is included in the civicrm module.

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: Views, Activities and Custom Fields
March 18, 2009, 06:16:34 am

no.  You might want to try doing a google search and some php sites out there might be able to give you better debugging info. The drupal forums might have more info. If you have the $$$, i;ve heard relatively good things with the Zend suite

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Views, Activities and Custom Fields
March 18, 2009, 11:32:46 am
The tricky thing is finding the right bit of code isn't it!

Did you try putting breakpoints in civicrm\drupal\modules\views\civicrm.views.inc in this function

function civicrm_views_data()

It seems to be where the data is retrieved from. Presumably you can add to it too.

nb I think eclipse is a good tool for this sort of thing - if you already know how to use it I wouldn't change it
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Views, Activities and Custom Fields
March 18, 2009, 04:39:04 pm
Thanks, I have been working towards putting breakpoints into the code at various points.. I found an article on debugging php using eclipse from IBM and an struggling through setting up the environment so that I can do the debugging - steep learning curve for a charity worker, and no Lobo, no big bucks -

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Views, Activities and Custom Fields
March 18, 2009, 05:16:00 pm
Did you get the debugger set up OK? You can download it bundled in http://www.zend.com/en/community/pdt

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Views, Activities and Custom Fields
March 20, 2009, 02:39:48 am
I didn't get on very well with Eclipse or Aptana... switched to...

Netbeans 6.5 + php which includes its own debugger and that seems to be working.

I can't say the same for the user who is currently more confused than ever - but still plodding away.

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Views, Activities and Custom Fields
March 20, 2009, 05:53:58 am
Ok the user is getting a little more savy and has identified where things break down (approximately)

the function civicrm_views_custom_data_cache starts with these lines...

    //Feels a bit hacky this next 10 lines but it was the only way I could get getTree to play nice with the data
    $config =& CRM_Core_Config::singleton( );
    if ($style == 'Inline') {
        $tree = CRM_Core_BAO_CustomGroup::getTree( $entity_type, CRM_Core_DAO::$_nullObject, $subType, null);
    }
    else {
        $tree = CRM_Core_BAO_CustomGroup::getTree( $entity_type, CRM_Core_DAO::$_nullObject, null, $groupID);
    }

I'm only testing Inline custom fields for now so... the problem occurs with this expression -

        $tree = CRM_Core_BAO_CustomGroup::getTree( $entity_type, CRM_Core_DAO::$_nullObject, $subType, null);

When the entity type is not a type of contact (Organisation, Household or Individual) but is instead something else (Relationship and Activity tested so far), the variable $tree is set to null. If the entity type is individual etc.. then tree is correctly loaded.

I'm going to take a break before trying to figure out why.

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Views, Activities and Custom Fields
March 20, 2009, 07:13:24 am
Got debugging to work with Eclipse + PDT + XDebug, now checking also.

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Views, Activities and Custom Fields
March 20, 2009, 07:40:11 am
Function call parameters are incorrect - added an extra two null's:

Line 2682 should read:

 $tree = CRM_Core_BAO_CustomGroup::getTree( $entity_type, CRM_Core_DAO::$_nullObject, null, null, $subType, null);

That way the variable $subType is passed through correctly, otherwise it is null.

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Re: Views, Activities and Custom Fields
March 20, 2009, 07:56:28 am
Thank you Eileen, thanks Lobo - issue raised and patch attached to it. Please let me know if I seem to have messed something else up!

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Views, Activities and Custom Fields
March 20, 2009, 10:13:54 am
Thank you, Myles.

I confirm - this solution works for me.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Views, Activities and Custom Fields
March 20, 2009, 11:33:34 am
well done
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Views, Activities and Custom Fields

This forum was archived on 2017-11-26.