How can I add custom button next to Save, Cancel on Account module and custom module?

Hi Team,

Can some one suggest us the way to add custom button next to SAVE, CANCEL Any module and custom Module.

Also please suggest how can we write some custom on the click of the button.

Regards,

Deepak

  • Hi Parag Mittal

    If the post really helped you, mark it as Answer Correct, Helpful and Like.

    By doing this we are giving appreciation for their work/help

    Regards

    Syad

  • Hi Ramana

    I am having problems getting the button to recognize the onclick function billToButtonFunt(). The error message is as follows:

    Uncaught ReferenceError: myButtonFunt is not defined. I am sending you my code, it seems that the .js file is not being recognized, however I did try clicking on the link to the js file on viewcode section and I can see the function clearly.

    <?php
    $viewdefs ['Leads'] =
    array (
    'EditView' =>
    array (
    'templateMeta' =>
    array (
    'form' =>
    array (
    'hidden' =>
    array (
    0 => '<input type="hidden" name="prospect_id" value="{if isset($smarty.request.prospect_id)}{$smarty.request.prospect_id}{else}{$bean->prospect_id}{/if}">',
    1 => '<input type="hidden" name="account_id" value="{if isset($smarty.request.account_id)}{$smarty.request.account_id}{else}{$bean->account_id}{/if}">',
    2 => '<input type="hidden" name="contact_id" value="{if isset($smarty.request.contact_id)}{$smarty.request.contact_id}{else}{$bean->contact_id}{/if}">',
    3 => '<input type="hidden" name="opportunity_id" value="{if isset($smarty.request.opportunity_id)}{$smarty.request.opportunity_id}{else}{$bean->opportunity_id}{/if}">',
    4 => '<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>',
    5 => '<script type="text/javascript" src="./custom/include/javascript/test.js"></script>',

    ),

    'buttons' =>
    array (
    0 => 'SAVE',
    1 => 'CANCEL',
    // Add This code
    2 =>
    array (

    'customCode' => '<input id="MyButton" title="My Button" class="button" type="button" name="MyButton" value="My Button" onclick="myButtonFunt();">',


    ),
    ),
    ),

  • Hello,

    I have tried this, I can't get it to work. I am using SugarCRM version 6.5. I am putting a button on detail view, not edit view, so this is what I put in my detailviewdefs.php:

    $viewdefs['Cases']['DetailView'] = array(
        'templateMeta' => array(

            'form' => array(
                array (         
                    'javascript' => '        
                         <script src="/custom/include/javascript/jquery-1.4.4.min.js" type="text/javascript"></script>  
                         <script src="/custom/modules/Cases/scripts/detailview/additionalInfoPopup.js" type="text/javascript"></script>  
                    ',  
                 ),

                'buttons' => array(...

    The paths you can see there are absolute, starting at my sugarcrm root folder. I have verified that the files are there by navigating to them directly in the browser. I put absolute paths there after some experimentation. Unfortunately nothing has worked.

    The button I have added has the event handler like you specified,

    onclick="myButtonFunt();"

    but when I click the button I get

    RefereneError: myButtonFunt is not defined

    The contents of additionalInfoPopup.js are exactly the same as your example.

    What am I doing wrong?

    EDIT: Some additional info:

    I have viewed the page source and  there isn't a mention of my included script files. Also when I view the debugger tab in Firefox, the script file additionalInfoPopup.js doesn't seem to be loaded.

    I have tried putting the 'javascript' =>   array both inside and outside the 'form' => array. Neither of these approaches worked.