by synolia

Quickly view the organizational hierarchy of any account or contact. Identify key decision makers and influencers using this handy dashlet. Know where a given contact fits in or how an account is structured.

Includes a 30 day guarantee
Try it Now

#1140 - SynOrgChart, console error in 7.5.0.1, "Uncaught TypeError: Cannot read property 'dispatch' of null"

Closed Bug? created by jks1989 Verified Purchase 4 years ago

After upgrading to 7.5.0.1 we've noticed this error in the browser console:

 FATAL[2015-2-3 19:52:47]: Uncaught TypeError: Cannot read property 'dispatch' of null at http://sugarcrm7local.yellow.co.nz/cache/include/javascript/sugar_sidecar.min.js?v=yzrpfJ9Fat1q5Djdrnu3Kg on line 7140
sugar_sidecar.min.js?v=yzrpfJ9Fat1q5Djdrnu3Kg:7140 Uncaught TypeError: Cannot read property 'dispatch' of null

the line in question is in the chart.js plugin,

(function(app){app.events.on('app:init',function(){app.plugins.register('Chart',['view'],{chart_loaded:false,chartCollection:null,chart:null,total:0,onAttach:function(component,plugin){this.on('init',function(){if(this.meta.config){return;}
app.events.on('preview:close',function(){if(_.isUndefined(app.drawer)||app.drawer.isActive(this.$el)){this.resize();}},this);this.layout.on('dashlet:collapse',function(collapse){if(!collapse){this.resize();}},this);this.layout.context.on('dashlet:draggable:stop',function(){this.resize();},this);$(window).on('resize.'+this.cid,_.debounce(_.bind(this.resize,this),100));this.handlePrinting('on');if(!_.isFunction(this.chartResize)){this.chartResize=this._chartResize;}
if(!_.isFunction(this.hasChartData)){this.hasChartData=this._hasChartData;}},this);this.on('render',function(){this.$('.nv-chart').on('click',_.bind(this.chart.dispatch.chartClick,this));this.renderChart();},this);},_hasChartData:function(){return this.total!==0;},_chartResize:function(){this.chart.update();},onDetach:function(){if(this.meta.config){return;}
if(this.layout){this.layout.off(null,null,this);}
if(this.layout&&this.layout.context){this.layout.context.off(null,null,this);}
$(window).off('resize.'+this.cid);this.handlePrinting('off');},isChartReady:function(){if(this.meta.config||this.disposed){return false;}
if(!this.$el||(this.$el.parents().length>0&&!this.$el.is(':visible'))){return false;}
if(!_.isFunction(this.chart)||!this.hasChartData()){this.chart_loaded=false;this.displayNoData(true);return false;}
this.displayNoData(false);return true;},resize:function(){if(!this.chart_loaded){return;}
if(!this.$el||(this.$el.parents().length>0&&!this.$el.is(':visible'))){return;}
this.chartResize();},handlePrinting:function(state){var self=this,mediaQueryList=window.matchMedia&&window.matchMedia('print');var pausecomp=function(millis){var date=new Date(),curDate=null;do{curDate=new Date();}while(curDate-date<millis);};var printResize=function(mql){if(mql.matches){if(!_.isUndefined(self.chart.legend)&&_.isFunction(self.chart.legend.showAll)){self.chart.legend.showAll(true);}
self.chart.width(640).height(320);self.resize();pausecomp(200);}else{browserResize();}};var browserResize=function(){if(!_.isUndefined(self.chart.legend)&&_.isFunction(self.chart.legend.showAll)){self.chart.legend.showAll(false);}
self.chart.width(null).height(null);self.resize();};if(state==='on'){if(window.matchMedia){mediaQueryList.addListener(printResize);}else if(window.attachEvent){window.attachEvent('onbeforeprint',printResize);window.attachEvent('onafterprint',browserResize);}else{window.onbeforeprint=printResize;window.onafterprint=browserResize;}}else{if(window.matchMedia){mediaQueryList.removeListener(printResize);}else if(window.detachEvent){window.detachEvent('onbeforeprint',printResize);window.detachEvent('onafterprint',browserResize);}else{window.onbeforeprint=null;window.onafterprint=null;}}},displayNoData:function(state){this.$('[data-content="chart"]').toggleClass('hide',state);this.$('[data-content="nodata"]').toggleClass('hide',!state);}});});})(SUGAR.App);

/* End of File include/javascript/sugar7/plugins/Chart.js */

or more specifically in the render function, this.chart.dispatch is being called when this.chart is null:

this.on('render', function () {
                    this.$('.nv-chart').on('click', _.bind(this.chart.dispatch.chartClick, this));
                    this.renderChart();
                }, this);

Cheers
Josh

  1. synolia member avatar

    synolia Provider Affiliate

    4 years ago

    Hello,

    To properly install the module please follow the steps described in the installation guide of the module that can be found here : https://www.sugaroutfitters.com/docs/sugarcrm-org-chart-hierarchy/installation-guide .
    It is important that after all the repair tasks have been done you disconnect your SugarCRM account and refresh the browser cache (using CTRL+F5 or CTRL+R). Once this is done you can reconnect to your SugarCRM account.

    If you have any other questions regarding the installation or usage of the dashlet, don't hesitate to contact us.

    Best regards,
    Support Synolia

This case is public. Please leave out any sensitive information such as URLs, passwords, etc.
Saving Comment Saving Comment...
Rating
  • "This is a great plugin - works exactly as described, and is really popular with our users."

    Read More Reviews

Keep up to date on the latest additions

We'll send you an email every month with handpicked add-ons, reviews, tricks and tips. Don't worry, we hate spam as much as you do.