HOWTO: Adding your own global functions

sugarcrmdevelopers —  September 6, 2011 — 10 Comments

I love it when one blog post leads to another. This time, it was a post about having a dropdown powered by a function rather than the normal array of static option, where a comment to the posted asked where they could put the function so it would be picked up automatically and done in an upgrade-safe way. Turns out there is such a place, and as pointed out it’s not well documented.

You have two places to pick from. You can either:

  • Put your function in the custom/include/custom_utils.php file
  • Add a new PHP file with your function in the custom/Extension/application/Ext/Utils/ directory and do a Quick Rebuild and Repair to have it become available.

The latter option is the much more preferable approach if you are developing module loadable modules, so you can cleanly add and remove custom global functions easily. If you are just doing a customization for your own instance, than the first approach will work fine.

10 responses to HOWTO: Adding your own global functions


    I have tried to place a file in custom/Extension/application/Ext/Utils/ and I am not able to get this to work. Any pointer? Which version does this work with?  Where does the generated file go?


    Does this work for adding a function to a bean, as well?


      this will create custom/application/Ext/Utils/utils.ext.php all functions in here are available everywhere


        In my case I need to add a custom function to a bean for dupeCheckFunction purposes on an Import. I can create a custom bean that extends the original bean but would like to avoid that. The function gets called in this manner: $this->_focus->$functionName($index); Would it still work for this in a util? Wondering if utils are even supported at the module level. Thanks!


          Utils are systemwide, and not module specific. However, with the advent of BeanFactory, we are soon able to support custom beans, hopefully in one of the next releases.


    I am using a function to populate drop down. works great on listview search def but it doesn’t work on the dashlet search def. Any one has an idea why?


    As of 6.7.0, simply using custom_utils.php doesn’t work anymore and you must use the Extension framework.

    custom/include/custom_utils.php just doesn’t get found/included.


    how should we add global function in sugar 7.6 professional edition, both the path mentioned custom/include/custom_utils.php and
    custom/Extension/application/Ext/Utils/custom_utils.php didn’t work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s