Matt Marum

Extending Sugar 7.1.5 Record View

Blog Post created by Matt Marum Employee on Feb 10, 2014
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.

 

custom_modules_Foo_clients_base_views_record_record.js

({
    extendsFrom: 'RecordView',

/**
     * Some extra functionality
*/
doSomethingCool: function() {
    },

_dispose: function() {
//additional stuff before calling the core create _dispose goes here
this._super('_dispose');
    }
})

 

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.

Outcomes