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 CiviReport (Moderator: Dave Greenberg) »
  • Defining the contact that custom data applies to in a report
Pages: [1]

Author Topic: Defining the contact that custom data applies to in a report  (Read 1497 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Defining the contact that custom data applies to in a report
September 21, 2010, 06:55:39 am
Hello there,

Here's a question about reporting that has come up a couple of times for me and I think should be generally useful.  It's come up for me in the relation report but I'm asking here in regard to the activity report.

By default the activity report allows you to look at Source Contact, Assignee Contact, and Target Contact.

When you extend it to include custom data about a contact, it assumes you mean custom data about the source contact but I want it to extend custom data about the *target* contact.

I have a hunch this is the more common use case to be honest, but in any case it would be great to know how to change things round.

It isn't obvious to me how the contact that custom data applies to is defined.  But maybe it is the contact with the alias contact_civireport?  How do I let Civi knoe which contact I want to extend with custom data?

A little bit of advice and instruction on whether I am headed in the right direction and what I should do next would be greatly appreciated :)

Cheers,
Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Defining the contact that custom data applies to in a report
September 21, 2010, 12:37:40 pm
There should be a join in there somewhere that is joining the custom table's "entity_id" on one of the contact table aliases (source contact). Change it to join on the target contact alias instead.

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Defining the contact that custom data applies to in a report
January 17, 2011, 08:09:30 am
OK - finally worked this out and attached is a patch.

IMO it makes much more sense to attach any contact custom data to the target contact (which is outside the organisation and likely to have a load of custom data that wants to be tracked) rather than the source or assignee which tend to be inside the organisation.

I can see the use case for the inside, but my hunch is that 95-9% of people will want to report on custom data of their contacts, not users.

Have filed an issue on this http://issues.civicrm.org/jira/browse/CRM-7396 with patch.  Would be great if people can input here to makes sure this is a sensible improvement.

In the patch I have also included custom data on 'contact, organisation and indivudual' by default.  Again, IMO, I think that reports are much more useful when the have custom data in them.  If it isn't the case already, I propose a convention of including custom data by default, otherwise using any custom data in reports becomes a 'Developer task' i.e. not able to be done via UI alone.

Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Defining the contact that custom data applies to in a report
January 17, 2011, 08:28:35 am
The idea is sound I think. Only thing I can see is that because it changes existing core behavior the upgrade path might need some extra code somewhere, i.e. if someone has existing custom data selected in an instance, those selections are stored in the database. If they are based on different contact types or subtypes then one set of custom data might not apply to all contacts and errors will result. Even if they do exist the results will be unexpectedly different than before the upgrade.

Is it better to submit the entire report simply as a new core report?

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: Defining the contact that custom data applies to in a report
January 21, 2011, 12:10:10 am
Hi Michael,

Regarding issue http://issues.civicrm.org/jira/browse/CRM-7396, what if any activity has more than one target contacts?
Attached diff will show the custom data of only first contact, which will look more confusing.

My suggestion is to, instead of display custom data of target contact in Activity report , we can modify the links of target, assignee contacts ( currently it is redirected to the contact summary )  to the Contact Report ( Summary ) instance. So that any user can update that instance accordingly to views the custom data of that contacts.

Rajan

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Defining the contact that custom data applies to in a report
January 21, 2011, 09:22:31 am
Hi Rajan,

Thanks a lot for pointing that out :)

In this specific use case, the client wants to answer a question along the lines of the following: "how many contacts with this certain attribute have we carried out this activity with".  So in fact the report should show a line per target contact.

In this clients case we can pretty much guaruntee that there is one target contact per activity (because that is how they carry out their work) but that won't always be the case and I think the solution here is to change the grouping from civicrm_activity to civicrm_activity_target.  Does that sound right / make sense to you?

Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Defining the contact that custom data applies to in a report
February 03, 2011, 12:43:02 am
Michael,

I think primary use case of this report is to give details about activity, so listing will have Activity + Custom data. For your case you need more information on target contacts ( activity can have multiple target contacts )
IMO it should be displayed as separate rows with it's custom data etc, to avoid confusion, especially when there are multiple targets etc..

So report should be like

Activity 1 info .......
                 target 1 info .......
                 target 2 info ......
Activity 2 info
               target 1 info .....
Activity 3 info
               target 1 info .....

and so on...

My recommendation would be to a develop separate report, rather than complicating current report :)

Kurund

Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Defining the contact that custom data applies to in a report

This forum was archived on 2017-11-26.