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) »
  • Custom Reports - Fail to Create Instance
Pages: [1]

Author Topic: Custom Reports - Fail to Create Instance  (Read 1317 times)

e_mason

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 1
  • Eliot Mason
  • CiviCRM version: 4.05
  • CMS version: Drupal 7
  • MySQL version: 5.1xx
  • PHP version: 3.53
Custom Reports - Fail to Create Instance
October 11, 2012, 05:57:38 am
We have some custom reports (very barebones wrappers around straight sql statements with no user interface) that worked in a previous deployment, but are not working under v4.2.  Before I dive into debugging and a possible patch, can anyone tell me if this is already a known problem?  I don't see anything in the issues board....

*******
The report template is recognized, and I can start the process of adding a report instance: a preview is created and after adding a title, etc the notice that an instance has been created appears.  But that's it - looking in the database (civicrm_report_instance) there is a instance, but without a title, description, permission or nav_id.  The nav table (civicdm_navigation) also has an entry for the report, but its missing most values.

Other custom reports (edited versions of CiviCRM reports, to add custom fields, etc) function as expected with instances and navigation entries.  We have also tried this across multiple sites with the same result.

*******
This is the test report (there is a matching tpl, of course).
Code: [Select]
<?php
require_once 'CRM/Report/Form.php';


class 
CRM_Report_Form_Contact_TestReport extends CRM_Report_Form {

function 
postProcess(){
    
$this->beginPostProcess();
    
    
$fullquery=
"SELECT
id from civicrm_contact
WHERE id < 100"
;
        
/*now register all the columns to display */
    
$this->_columnHeaders =
        array (
'id'=> array ('title' => 'CiviCRM ID'),
                );
                
    
$this->buildRows ($fullquery, $rows);
    
$this->formatDisplay($rows);
    
$this->doTemplateAssignment( $rows );
    
$this->endPostProcess( $rows );
    
    }
}
?>


hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Custom Reports - Fail to Create Instance
January 28, 2013, 11:35:32 am
I'm seeing a similar issue on a system that was recently upgraded to 4.2.7.

As a workaround, I am editing the civicrm_report_instance table manually to get the values corrected.  I'll let you know if I find or hear of a better solution.

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Custom Reports - Fail to Create Instance
January 28, 2013, 12:09:58 pm
p.s.  I am also, as a workaround, editing the civicrm_navigation table, so that I can add the report to a menu, as this table is also missing information for the custom report instance, although a record is created.

poorhaus

  • I’m new here
  • *
  • Posts: 29
  • Karma: 0
    • Music Nova Scotia
  • CiviCRM version: 4.4.10
  • CMS version: Drupal 7
  • MySQL version: 5.5.27
  • PHP version: 5.3.17
Re: Custom Reports - Fail to Create Instance
January 21, 2014, 08:33:19 am
I am having the same issue with a similarly simple custom report template, under Civi 4.2.14.

Code: [Select]
<?php

class CRM_Report_Form_Member_ByRegion extends CRM_Report_Form {

function 
postProcess( ) {

        
$this->beginPostProcess( );
 
        
// note1: your query
        
$myQuery = "SELECT region_30, count(*) as number, (count(*) / (select count(*) from civicrm_membership WHERE owner_membership_id IS NULL AND status_id >0 AND status_id <4)  * 100.00) as percentage 
FROM `civicrm_value_membership__organization__2` 
RIGHT JOIN civicrm_membership ON civicrm_value_membership__organization__2.entity_id=civicrm_membership.contact_id 
WHERE status_id >0 AND status_id <4 AND owner_membership_id IS NULL 
GROUP BY region_30
WITH ROLLUP
"
;
 
        
// note2: register columns you want displayed-
        
$this->_columnHeaders =
                array( 
'region_30' => array( 'title' => 'Region' ),
                       
'number'  => array( 'title' => 'Number' ),
                       
'percentage' => array( 'title' => 'Percentage' ),
                       );
        
// note3: let report do the fetching of records for you
        
$this->buildRows ( $myQuery, $rows );
 
        
$this->formatDisplay($rows);
 
     // some debug
 // drupal_set_message(print_r($this));

        
$this->doTemplateAssignment( $rows );
        
$this->endPostProcess( $rows );
 
 
     } 
// post process ends



} // class ends

?>

I can register the template, but trying to create an instance of it fails with four PHP notices:
Quote
Notice: Undefined index: report_footer in CRM_Report_Form_Instance::postProcess() (line 243 of /home/musicnova/www/www/sites/all/modules/civicrm/CRM/Report/Form/Instance.php).
Notice: Undefined index: parent_id in CRM_Core_BAO_Navigation::add() (line 107 of /home/musicnova/www/www/sites/all/modules/civicrm/CRM/Core/BAO/Navigation.php).
Notice: Undefined index: title in CRM_Report_Form_Instance::postProcess() (line 248 of /home/musicnova/www/www/sites/all/modules/civicrm/CRM/Report/Form/Instance.php).
Notice: Undefined index: title in CRM_Report_Form_Instance::postProcess() (line 247 of /home/musicnova/www/www/sites/all/modules/civicrm/CRM/Report/Form/Instance.php).

A success message is mistakenly shown when this occurs:
Quote
Report "" has been created and is now available in the report listings under "Member" Reports.

Unlike the OP, a row is not added to civicrm_report_instance when this occurs. I am selecting a parent navigation item when I submit the form, as I've read about a known issue with leaving that field blank.


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviReport (Moderator: Dave Greenberg) »
  • Custom Reports - Fail to Create Instance

This forum was archived on 2017-11-26.