Suitecrm: SUGAR.settings is undefined

Created on 10 Jul 2019  路  3Comments  路  Source: salesagility/SuiteCRM



Issue


According to documentation, using $this->addDomJS($data, 'vardefs'); within a custom view should make vardefs accessible in Javascript but the SUGAR.settings object is undefined

Expected Behavior


The vardefs (or any other object) should be accessible through JavaScript. https://docs.suitecrm.com/images/en/developer/vardefs.png

Actual Behavior



SUGAR.settings object is undefined, no error logs. suitecrm.log is empty, php error.log is empty too and no warnings or errors are shown in the browser console.

Possible Fix


Sorry, I have no possible fix but maybe is related to issue #3006 and pr #3008

Steps to Reproduce


  1. Create a custom view class
class ViewCustomDetail extends ViewDetail
{
    public function __construct()
    {
        parent::__construct();
        $this->useForSubpanel = true;
        $this->useModuleQuickCreateTemplate = true;
        $data = $this->getVardefsData('pud_Applicant');
        $this->addDomJS($data, 'vardefs');
        $jose = array(
            'name' => 'Jose',
            'country' => 'Argentina',
            'footballTeam' => 'River Plate',
            'footballTeamLastTitles' => array(
                'Copa Sudamericana 2014',
                'Copa Libertadores de Am茅rica 2015',
                'Copa Suruga Bank 2015',
                'Recopa Sudamericana 2015',
                'Recopa Sudamericana 2016',
                'Copa Libertadores de Am茅rica 2018',
            ),
        );
        $this->addDomJS(array($jose), 'developerData');
    }

    public function display()
    {
         parent::display();
    }
}
  1. Custom controller overriding detail view
class pud_ApplicantController extends SugarController
{
    protected function action_detailview()
    {
        //set the new custom view
        $this->view = 'customdetail';
    }
}
  1. Install the module, quick repair and rebuild
  2. Access the custom view in the browser and try to print SUGAR.settings object in the console

Context



I'm trying to read bean data from JavaScript so I can use it in a custom script to display a pdf document conditionally using PDFJS.

Your Environment

  • SuiteCRM Version used: Version 7.11.6 / Sugar Version 6.5.25 (Build 344)
  • Browser name and version: Gecko/20100101 Firefox/67.0 64 bit
  • Environment name and version: Ubuntu 18.04 LTS, MariaDB 10.1, Apache 2.4.29
  • Operating System and version: Macintosh; Intel Mac OS X 10.14; rv:67.0
Important Bug

Most helpful comment

Hi @pgorod

I have found that this problem appears only if you use AjaxUI.
If you do not use AjaxUI everything works fine.

I keep investigating...

All 3 comments

@Abuelodelanada you might want to take a look at this

Hi @pgorod

I'll take a look!

Hi @pgorod

I have found that this problem appears only if you use AjaxUI.
If you do not use AjaxUI everything works fine.

I keep investigating...

Was this page helpful?
0 / 5 - 0 ratings