How can I get value in config_override.php via js

Hi all,

I would like to get parameters in config_override.php pass into .hbs via js controller

I try with this code below but doesn't work.

var custom = app.lang.getAppListStrings('custom_value');
this.testData = custom;

then return:

[object Object]

How to do this ?

Sugarcrm 7.6

Thanks,

M

Parents
  • I don't think this is possible out of the box (although I have a workaround below) for security reasons. The values in config/config_override include stuff like database connection details, which you might not even want your highest privileged application users (i.e. Administrators) to know. The way I'd implement this is by creating a custom endpoint:

    http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/API/Web_Services/Extending_Web_Servi…

    The main change I'd make to the endpoint api in the example is:

     public function MyGetMethod($api, $args){
      global $sugarconfig;
      return $sugarconfig['custom_value'];
      }
    

    You could then get the value using the loadData function in your controller like this:

    loadData: function () {
            var _this = this;
            App.api.call('GET', App.api.buildURL('name_of_your_endpoint', null, null, ''), null, {
                success: function (custom_value) {
                    _this.custom_value = custom_value;
                    _this.render();
                }}
            );
        },
    

    Let me know if you have any trouble with this method.

Reply
  • I don't think this is possible out of the box (although I have a workaround below) for security reasons. The values in config/config_override include stuff like database connection details, which you might not even want your highest privileged application users (i.e. Administrators) to know. The way I'd implement this is by creating a custom endpoint:

    http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.6/API/Web_Services/Extending_Web_Servi…

    The main change I'd make to the endpoint api in the example is:

     public function MyGetMethod($api, $args){
      global $sugarconfig;
      return $sugarconfig['custom_value'];
      }
    

    You could then get the value using the loadData function in your controller like this:

    loadData: function () {
            var _this = this;
            App.api.call('GET', App.api.buildURL('name_of_your_endpoint', null, null, ''), null, {
                success: function (custom_value) {
                    _this.custom_value = custom_value;
                    _this.render();
                }}
            );
        },
    

    Let me know if you have any trouble with this method.

Children
No Data