SugarCRM: Create button on the detail view

To create a custom button on the detail view of a module {MODULE_NAME} use the below code

Create a file or modify the below file custom/modules/{MODULE_NAME}/views/view.detail.php

<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
require_once('include/json_config.php'); 
require_once('include/MVC/View/views/view.detail.php'); 
require_once('custom/include/general_functions.php');
class {MODULE_NAME}ViewDetail extends ViewDetail
{
    function {MODULE_NAME}ViewDetail()
    {
        parent::ViewDetail();
    }
    function display()
    {
        $this->dv->defs['templateMeta']['form']['buttons'][101] = array (
            'customCode' => '<input title="Custom Text Here" accesskey="{$APP.LBL_PRINT_PDF_BUTTON_KEY}" class="button" onClick="javascript:CustomFunctionHere();" name="tckpdf" value="Custom Text Here" type="button">');
        parent::display();
    }
}
?>
Advertisements
SugarCRM: Create button on the detail view

8 thoughts on “SugarCRM: Create button on the detail view

  1. I modify in custom/module/Leads/views/view.detail.php

    My code :

    $GLOBALS[‘listbutton’] = $this->dv->defs[‘templateMeta’][‘form’][‘buttons’]; if ($this->bean->status == ‘Converted’) {
    unset($this->dv->defs[‘templateMeta’][‘form’][‘buttons’][0]);
    }
    parent::display();

    $GLOBALS[‘log’]->debug(“INFOdation log Display”);
    $this->dv->defs[‘templateMeta’][‘form’][‘buttons’] = $GLOBALS[‘listbutton’];
    But when status ==’New’ , the edit button still hide. Could you help me. I only want edit button hide when status == ‘Converted’, other status it has to apperance.

    Like

  2. Hy thx , it was very usefull.
    can u please tell me how i can embedded javascript code in this view.detail.php?
    because i want to dynamically hide and display panel. Thx
    Stev

    Like

  3. Really useful. Before this I was trying to do it through the metadata because that’s where I saw the other buttons defined but this is much cleaner. Now I just have to tie this to an event handler and all will be good. Thanks!

    Like

  4. I precisely had to thank you so much once again. I am not sure the things that I could possibly have accomplished without the tips discussed by you over my question. It was the difficult scenario for me, but taking note of a new professional way you processed the issue forced me to leap for happiness. Extremely happier for this work and in addition wish you comprehend what a great job you’re getting into instructing others thru your blog post. Most probably you’ve never got to know any of us.

    Like

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