Adding javascript files to Edit and Detail Views

John Mertic —  September 6, 2013 — 1 Comment

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.

One response 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?

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