Adding javascript files to Edit and Detail Views

John Mertic —  September 6, 2013 — 5 Comments

I came across a great blog post today from fellow community member Greg Ambrose, where he addressed the issue on including javascript files into the edit and detail forms. The metadata framework is great for this, and he has a nice example on how to do this. Here’s the three step process…

1. Add a reference to the javascript file you are going to add at the end of custom/modules/<<modulename>>/metadata/[edit|detail]viewdefs.php


$viewdefs['Opportunities']['EditView']['templateMeta']['includes'] =
    array (
        array (
        'file' => 'path/to/file/filename.js',

2. Add the javascript file you want to include into the location you referenced above.

3. Quick Repair, then browser refresh

Thanks Greg for this great tip!

John Mertic


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.

5 responses to Adding javascript files to Edit and Detail Views


    Hey there,
    In reference to this:

    How can I reference the same to hide Convert lead, Delete, Edit in CE 6.5.16?


    Does this still work for sidecard modules in 7.6? I remember i tried it and couldn’t include any javascript this way. Tried to include it inside an .hbs file also failed.


    Hello , kinda managed however having trouble accessing model information from the view in some case.
    How would I have access to this.model.get / set for the current record from the hbs ?
    For example having this form in the view hbs file that fills in the data in the form based on the json.
    How would I construct that json with info from the model like the id and other info.

    In sugar I have another field that can hold this information like

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