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) »
  • SQL error for custom field in CiviCase Report
Pages: [1]

Author Topic: SQL error for custom field in CiviCase Report  (Read 737 times)

Erawat

  • I’m new here
  • *
  • Posts: 19
  • Karma: 1
  • CiviCRM version: 4.1
  • CMS version: Drupal 7
  • MySQL version: 5.x
  • PHP version: 5.3
SQL error for custom field in CiviCase Report
January 18, 2012, 10:47:25 am
Hi

I have created a custom data set and attached into activity type for CiviCase.

I have modified the exsiting report which is Case Detail Report by adding

Code: [Select]
    protected $_customGroupExtends = array( 'Activity' );

So the Report Criteria shows the set of custom fields that I created but when I try to preview the report. The DB error occurs.  The error occurs around line 498 which is

Quote
     $this->buildRows ( $sql, $rows );

Then I print the SQL to see if there and problem in SQL so I can see they is a problem of SQL in the highlight below

Code: [Select]
SELECT SQL_CALC_FOUND_ROWS case_civireport.id AS civicrm_case_id, case_civireport.subject AS civicrm_case_subject, contact_civireport.sort_name AS civicrm_contact_client_sort_name, contact_civireport.id AS civicrm_contact_id
FROM civicrm_case case_civireport
LEFT JOIN civicrm_case_contact civireport_case_contact ON civireport_case_contact.case_id = case_civireport.id
LEFT JOIN civicrm_contact contact_civireport ON contact_civireport.id = civireport_case_contact.contact_id
LEFT JOIN civicrm_address address_civireport ON contact_civireport.id = address_civireport.contact_id
AND address_civireport.is_primary =1
LEFT JOIN civicrm_value_initial_assessment_6 value_initial_assessment_6_civireport ON value_initial_assessment_6_civireport.[b][color=red]entity_id = .id[/color][/b]
WHERE ( 1 )
GROUP BY case_civireport.id
ORDER BY case_civireport.start_date DESC
LIMIT 0 , 50

Can anyone help me where do I have to add or changed in the code in order to make it works.

Thank you

Erawat

Mark Tompsett

  • I post frequently
  • ***
  • Posts: 143
  • Karma: 9
    • QualityTime Services Ltd
  • CiviCRM version: 4.3.4
  • CMS version: Drupal 7.22
  • MySQL version: 5.5.30-cll
  • PHP version: 5.3.23
Re: SQL error for custom field in CiviCase Report
January 23, 2012, 12:29:15 am
Without knowing what is in your civicrm_value_initial_assessment_6 table I would have to guess what it's entity_id column refers to but if it is the contact id then the 'ON' clause of the LEFT JOIN would have to read
Code: [Select]
value_initial_assessment_6_civireport.entity_id = civireport_case_contact.idHope that helps.   :-\

Mark

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • SQL error for custom field in CiviCase Report

This forum was archived on 2017-11-26.