This discussion is archived
7 Replies Latest reply: Nov 29, 2012 12:50 PM by 627092 RSS

Apex 4.1.1 upgrade gives javascript errors with custom js

bjarkekr Newbie
Currently Being Moderated
Hi,

I have a small script which does several differing things when an interactive report is present. To see if the actual page has an IR, I use the following js:
;(function($){
$.htmldbIrBusyGrap=$.fn.htmldbIrBusyGrap=function(){
/* for bind IR ajax */
 /* check do we have IR on page */
 if($('#apexir_WORKSHEET_REGION').length>0){
  /* replace apex internal function _BusyGraphic */
  gReport._BusyGraphic=function(pState){
   if(pState==1){
    /* ir ajax start trigger htmldbIrAjaxStart event and show loading icon */
    $.event.trigger('htmldbIrAjaxStart');
    $('#apexir_LOADER').show();
   }else{
    /* check is there data stored to #apexir_WORKSHEET */
    if(!$('#apexir_WORKSHEET').data('htmldb')){
      /* store data to #apexir_WORKSHEET */
      $('#apexir_WORKSHEET').data('htmldb',{irReady:true});
      /* trigger htmldbIrReady event */
      $.event.trigger('htmldbIrReady');
     }
     /* hide loading icon and trigger htmldbIrAjaxEnd*/
     $('#apexir_LOADER').hide();
    $.event.trigger('htmldbIrAjaxEnd');
   };
return;
};
$.event.trigger('htmldbIrReady');
}
};

(The code from the following post: Apex 3.2 hook javascripts to IR and execute those when report is refreshed and has worked fine in 4.1)

Now when I run my application I get the following javascript error:
gReport is undefined
on this line: gReport._BusyGraphic=function(pState){


I dont really undestand why, because I cant see any changes from 4.1 to 4.1.1 in the files referring to gReport. Also the standard APEX html output also references gReport.

Maybe there has been some functions changing name or something??
  • 1. Re: Apex 4.1.1 upgrade gives javascript errors with custom js
    riedelme Expert
    Currently Being Moderated
    bjarkekr wrote:
    (The code from the following post: Apex 3.2 hook javascripts to IR and execute those when report is refreshed and has worked fine in 4.1)

    Now when I run my application I get the following javascript error:
    gReport is undefined
    on this line: gReport._BusyGraphic=function(pState){

    I dont really undestand why, because I cant see any changes from 4.1 to 4.1.1 in the files referring to gReport. Also the standard APEX html output also references gReport.

    Maybe there has been some functions changing name or something??
    Look at the page source Apex is generated when the error occurs. Search the HTML source file for gReport; I expect you will find that gReport is not referred to prior to the line you referred to on the page. Your former use of it may have defined the object in a way that is not happening now. If you have access to the old system see how and where on the page the object was defined and duplicate the definition in your new system

    If you can't find where/where gReport is defined you will have to do something else.
  • 2. Re: Apex 4.1.1 upgrade gives javascript errors with custom js
    bjarkekr Newbie
    Currently Being Moderated
    Hi,

    I actually have been looking at the html source of both 4.1 system and 4.1.1 to see any changes. I cant see any and the apex generated code also references gReport in f.x. the Actions button of the IR.

    By going through every change in the .js files and the html source code of the generated html I could probably find the change that causes the error, but it would be a lot easier if one from the apex team could tell me right away if they have made a change that causes the error :)
  • 3. Re: Apex 4.1.1 upgrade gives javascript errors with custom js
    Marco1975 Newbie
    Currently Being Moderated
    Hi,

    i have exactly the same error when upgrading tot 4.1.1.
    In APEX 4.1.0 everything is working fine, but now in 4.1.1 in every IR report i got "gReport is empty or undefined" error message.
    <script language="JavaScript" type="text/javascript">
    ;(function($){
    gReport = new apex.worksheet.ws('');
    $.htmldbIrBusyGrap=$.fn.htmldbIrBusyGrap=function(){
    /* for bind IR ajax */
     /* check do we have IR on page */
     if($('#apexir_WORKSHEET_REGION').length>0){
      /* replace apex internal function _BusyGraphic */
      gReport._BusyGraphic=function(pState){
       if(pState==1){
        /* ir ajax start trigger htmldbIrAjaxStart event and show loading icon */
        $.event.trigger('htmldbIrAjaxStart');
        /*goModal('apexir_LOADER', {position:['30%',]});*/
         html_ShowElement('waitRegion'); 
        //$('#waitRegion').modal({persist:true,overlayCss:{backgroundColor:'#606060'},position:['30%',]});
        }else{
        /* check is there data stored to #apexir_WORKSHEET */
        if(!$('#apexir_WORKSHEET').data('htmldb')){
          /* store data to #apexir_WORKSHEET */
          $('#apexir_WORKSHEET').data('htmldb',{irReady:true});
          /* trigger htmldbIrReady event */
          $.event.trigger('htmldbIrReady');
         }
         /* hide loading icon and trigger htmldbIrAjaxEnd*/
             html_HideElement('waitRegion'); 
         //$.modal.close();
        $.event.trigger('htmldbIrAjaxEnd');
       };
       return;
      };
      $.event.trigger('htmldbIrReady');
     }
    };
    $.htmldbIrReady=$.fn.htmldbIrReady=function(fn){
     $(function(){if($.isFunction(fn)&&$('#apexir_WORKSHEET_REGION').length>0){$('#apexir_WORKSHEET_REGION').bind('htmldbIrReady',fn)}});
    };
    })(jQuery);
    addLoadEvent(function(){$.htmldbIrBusyGrap();});
    </script>
    When i add the following line in the javascript just above the call of the gReport
    gReport = new apex.worksheet.ws('');
    then the pages are loaded without any error, but my custom icon is not displayed.
  • 4. Re: Apex 4.1.1 upgrade gives javascript errors with custom js
    bjarkekr Newbie
    Currently Being Moderated
    Im glad im not the only one with the problem :) and I have solved it yet. So we are still on 4.1.0.
  • 5. Re: Apex 4.1.1 upgrade gives javascript errors with custom js
    bjarkekr Newbie
    Currently Being Moderated
    Offcause I meant I havent solved it instead of have
  • 6. Re: Apex 4.1.1 upgrade gives javascript errors with custom js
    jariola Guru
    Currently Being Moderated
    Hi,

    You should not use this "hack" on APEX 4.x. You should transfer your logic to dynamic actions.


    Regards,
    Jari

    -----
    My Blog: http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai
  • 7. Re: Apex 4.1.1 upgrade gives javascript errors with custom js
    627092 Newbie
    Currently Being Moderated
    I had the same issue with 4.2 when I upgrade from 4.0
    I resolved it by adding this js script in page html header.
    <script type="text/javascript" src="'+apex_img_dir+'libraries/apex/minified/widget.interactiveReport.min.js?v=4.2.0.00.27"></script>

    or using the js code
    $('<script type="text/javascript" src="'+apex_img_dir+'libraries/apex/minified/widget.interactiveReport.min.js?v=4.2.0.00.27"></script>').insertAfter('#apex-dev-toolbar');

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points