Extending Sugar 7 Record View

John Mertic —  February 10, 2014 — 7 Comments

We often get asked how to extend the Record view in Sugar 7. The Record view in Sugar 7 is one of the more complex views in the application so extending it can be a little tricky.

The examples below are based on Sugar 7.1.5.

The first question I would ask is “are you overriding the Record view for a single module?”

In that case, then what you need can be accomplished using a single file. All you need to do is define your custom module Record view.  Create your new Record view under custom/modules/MODULE/clients/views/. This is fairly easy and upgrade safe.

If you needed to change all Record views then the next question I would ask is “are you just trying to add something to the Record layout?”

Adding a new view to the Record layout would be the (upgrade) safest way to add content to the base Record user interface in Sugar 7.

https://gist.github.com/mmarum-sugarcrm/8744135

This is what Sugar 7 looks like when you have the files above dropped into your custom/ directory. Underscores in the file names above are used to denote subdirectories.

 

This gives you the freedom of having full control over your view without worrying about interactions with other components may also be trying to override the Record view.  It also keeps your customizations from being tightly coupled to the Record view so that it can be reused in more places in the user interface.

But if you really need to override the base Record view in Sugar 7 to accomplish your goals, here a recommended way to do it.

https://gist.github.com/mmarum-sugarcrm/8657382

Try dropping the files above into your custom/ directory.  Underscores in the file names above are used to denote subdirectories.

This approach involves creating a custom Record view with a different name.  The new view controller extends Record view and configures it appropriately so that it pulls in all the original record metadata including actions and fields.  In the custom view metadata, it is setup so that it reuses the Handlebars template from the original Record view.  You can then define any custom HTML that you need within separate templates that get serialized to the client along with your custom view.

I hope that helps!  Let us know if you’ve got questions.

John Mertic

Posts

John Mertic manages the strategic ISV alliances program for SugarCRM, having several years of techincal experience bringing solutions to market with several SugarCRM technology partners. A frequent conference speaker and an avid writer, he has been published in php|architect, IBM Developerworks, and in the Apple Developer Connection, and is the author of the book 'The Definitive Guide to SugarCRM: Better Business Applications' and the book 'Building on SugarCRM: Creating Applications the Easy Way'. He is also president of the OpenSocial foundation, guiding them in solving interoperability issues for enterprise application providers worldwide.

7 responses to Extending Sugar 7 Record View

  1. 
    Fernando da Silva Trevisan February 10, 2014 at 11:22 am

    Am I missing something or the article is missing a image – the one that show how Sugar 7 will look like when you drop the files in the custom directory?

    Thanks for the post!

  2. 

    When you say “drop the files”, you mean using a manifest I suppose… How do I just “drop” the files in sugaronemand?

    What happened to custom/Extension ? isn’t there anymore?

    • 
      Matthew Marum May 27, 2014 at 11:26 am

      Yes, for SugarOnDemand you would have to use a module loadable package.

      custom/Extension is still around. Support for using Extensions to extend Sidecar metadata was added in 7.2.0 with more enhancements planned.

  3. 

    This just does not work at my end. Are you sure that you have given us the appropriate filenames & paths?

    • 
      Matthew Marum May 27, 2014 at 11:28 am

      If you are having problems getting this to work, make sure you have tried to use Quick Repair & Rebuild.

Trackbacks and Pingbacks:

  1. Disable/Enable dropdown on change of another field | Rolustech Blog - April 29, 2014

    […] First we will need to extend and override record view controller. Record view can be extended following the guidelines in Extending Sugar7 Record View. […]

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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