Customer Portal

Get Involved. Join the Conversation.

Topic

    Dat N
    Changing report_id number dynamically
    Topic posted September 24, 2013 by Dat NRed Ribbon: 250+ Points 
    1110 Views, 22 Comments
    Title:
    Changing report_id number dynamically
    Content:

    Hello,

     

    I created a report_id = 120 to display in list2.php.  What I want is when someone click on the Search button (using search panel), I want the search function to use report_id = 130.  I am not sure if I make any sense, but if you know what I mean, please let me know how do I do it.

    Thank You

    Dat

    Code Snippet:

    Comment

    • Dat N

      Hi Matt,

      For some reasons it could not see reportId 130.  reportId does exist but for whatever reason it returns "Result not found".  Do you know why ?

      Thanks for your help!

       

      hooks.php

      ----------------------------------------------------------------------------------------

      $rnHooks['pre_report_get'][] = array(
          'class' => 'reporthook_model',
          'function' => 'preReportGet',
          'filepath' => ''
      );

       

      reporthook_model.php

      ------------------------------------------------------------------------------------------

      <?php


      class reporthook_model extends Model
      {
          function __construct()
          {
              parent::__construct();
          }

          public function preReportGet($filters)
          {
              if ($filters['data']['reportId'] == 120)
              {
                  $filters['data']['reportId'] = 130;
              }
          }
      }

    • Jeremy Watson

      Dat,

      Could it be that report 130 is running, but, based on the filters, there are simply no results to display?  If you don't have the hook function modify any data, do you get results from report 120?

      James

    • Matthew Workman

      Hi Dat,

      I agree you should try running the report in the console with the filters that are being passed from the customer portal. If all else fails copy the report and then modify it to meet your needs. You don't have to use the default it you don't want to.

       

      Regards,

      Matthew

    • Dat N

      To answer James questions, the report 130 is not running.  I get the results if I ran the report 130 manually through the Report Explorer.  I also get results from report 120 if I don't have the hook function.  Also, if I switched it around (130 --> 120) I still get the no results.  So the point is no matter what report number I put after the If statement I get the no result back even though the report id is there and I get the results if I ran it manually.

       

      class reporthook_model extends Model
      {
      function __construct()
      {
      parent::__construct();
      }

      public function preReportGet($filters)
      {
      if ($filters['data']['reportId'] == 120)
      {
      $filters['data']['reportId'] = 130;
      }
      }
      }

    • Matthew Workman

      Hi Dat,

       

      I finally looked at the reports and they are very different. What are you using to display the results. Which widget ?

      The filters available for each report are also very different which may be causing a problem. Are you using a standard page or custom.

      Regards,

      Matthew

    • Dat N

      Hi Matt,

      What I did was I copied report 176 (which is a default report), renamed it and put in filter.  I am using rn: container.

      Is that helped ?

       

      Thank You,

    • Jeremy Watson

      Dat,

      One additional thing to try is to add an ampersand to the function call.  It may be a pass-by-reference issue:

      public function preReportGet(&$filters)

      Does that help?

      James