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) »
  • No records using custom search for report
Pages: [1]

Author Topic: No records using custom search for report  (Read 732 times)

xaviershay

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: 5
  • MySQL version: 5
  • PHP version: 5
No records using custom search for report
April 17, 2011, 10:16:28 pm
I am using a custom search of my own writing:
gist.github.com/f27bf2766a3a0f7ac15c

When I run this search, it returns 9 records (correct).
When I create a smart group from that search, then search for all contacts in that smart group, it returns 8 records.
When I create a report with criteria "In Group <my smart group>" it returns 0 records.

I am not sure how to debug this issue. Any suggestions as to what might be wrong?

Cheers,
Xavier

xaviershay

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: 5
  • MySQL version: 5
  • PHP version: 5
Re: No records using custom search for report
April 17, 2011, 11:03:26 pm
I created a new report, and this appeared to work. I then deleted one of the contacts in the report (a test user) and now the report is empty again. Really at a loss to explain what is happening.

xaviershay

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: 5
  • MySQL version: 5
  • PHP version: 5
Re: No records using custom search for report
April 18, 2011, 12:09:33 am
I used the devel module to inspect the SQL that is getting run, which has helped me narrow down the problem. The relevant clause from the report query is:

    SELECT DISTINCT cgroup_civireport.contact_id
                                 FROM   civicrm_group_contact cgroup_civireport
                                 WHERE  ( cgroup_civireport.group_id IN ( 27 ) )
                                        AND cgroup_civireport.status = 'Added'
                                 UNION DISTINCT
                                 SELECT DISTINCT smartgroup_contact.contact_id
                                 FROM
       civicrm_group_contact_cache smartgroup_contact
                                 WHERE  smartgroup_contact.group_id IN ( 27 ))
       AND contact_civireport.id IN (SELECT DISTINCT tag_civireport.entity_id
                                     FROM   civicrm_entity_tag tag_civireport
                                     WHERE  entity_table = 'civicrm_contact'
                                            AND ( tag_civireport.tag_id IN ( 6 )
                                                )

I am not sure where the first SELECT comes from, as it doesn't scope by tag - perhaps this is for contacts manually added to the smart group?
The second select would be correct, except civicrm_group_contact_cache is empty! Is this supposed to be the case? Can I force a refresh of it?
« Last Edit: April 18, 2011, 12:17:53 am by xaviershay »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • No records using custom search for report

This forum was archived on 2017-11-26.