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

Parents
  • Hi Parag Mittal

    This post may help you.

    Let me know if you need more help.

    Best Regards

    S Ramana Raju

  • Hi Ramana,

    Thanks for your reply.

    It is little confusing for me.

    I am attaching the screen shot where i want to add custom button for your better understanding.

    Can you suggest more examples.

    Regards,

    Deepak

  • Hi Parag Mittal

    Okay, you are using sugar 6.x.

    custom/modules/Accounts/metadata/editviewdefs.php and add this code:

    'templateMeta' => 
        // Add this code
        array (        
           'javascript' => '       
                <script src="./include/javascript/jquery.min.js" type="text/javascript"></script> 
                <script src="./custom/include/javascript/test.js" type="text/javascript"></script> 
           ', 
        ),        
        array (
           '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();">',
            ),
        ),

    Now in your custom/include/javascript/test.js file write all your script code to do so:
    $(document).ready(function(){
       function myButtonFunt(){   

            console.log("Hi Friends am Triggered..");

       }
    });
    Once check with this approach and let me know if you found any issues.
    Hope this Helps

    Best Regards

    S Ramana Raju

  • Hi Ramana,

    Thanks for the Reply.

    Just a though, all above code should not be the part of Extension folder as it is custom code?

    It may cause issues with other customization.

    Or frame work will take care of it.

    Regards,
    Deepak

  • Hi Parag Mittal

    We can write all our customization inside custom folder.

    Its a upgrade safe only.

  • Hi Ramana,

    The code which u shared is working fine. I am trying to add one more Button but it is not working. 

    can  please suggest how can i add one more custom Button.

    Following is working code:

    array (
    'buttons' =>
    array (
    0 => 'SAVE',
    1 => 'CANCEL',
    // Add Custom Code
    2 =>
    array (
    'customCode' => '<input id="BillToValidateButton" title="Bill To Button" class="button" type="button" name="BillToButton" value="Bill To Validate" onclick="myButtonFunt();">',
    ),
    ),

    I want to add one more Button next to my Custom Button following is the code i am trying but it is not working.

    array (
    'buttons' =>
    array (
    0 => 'SAVE',
    1 => 'CANCEL',
    // Add Custom Code
    2 =>
    array (
    'customCode1' => '<input id="BillToValidateButton" title="Bill To Button" class="button" type="button" name="BillToButton" value="Bill To Validate" onclick="myButtonFunt();">',
    'customCode2' => '<input id="ShipToValidateButton" title="Ship To Button" class="button" type="button" name="ShipToButton" value="Ship To Validate" onclick="myButtonFunt();">',
    ),
    ),

    I am not able to find the root cause why it is not working can you please help me.

    Regards,

    Deepak 

  • Following code is working:

    array (
    0 => 'SAVE',
    1 => 'CANCEL',
    // Add Custom Code
    2 =>
    array (
    'customCode' => '<input id="BillToValidateButton" title="Bill To Button" class="button" type="button" name="BillToButton" value="Bill To Validate" onclick="billToButtonFunt();">
    <input id="ShipToValidateButton" title="Ship To Button" class="button" type="button" name="ShipToButton" value="Ship To Validate" onclick="shipToButtonFunt();">',
    ),

    Thanks

  • Try this:

    array(
        'buttons' =>
        array(
            0 => 'SAVE',
            1 => 'CANCEL',
    // Add Custom Code
            2 =>
            array(
                'customCode1' => '<input id="BillToValidateButton" title="Bill To Button" class="button" type="button" name="BillToButton" value="Bill To Validate" onclick="myButtonFunt();">',
            ),
            3 => array(
                'customCode2' => '<input id="ShipToValidateButton" title="Ship To Button" class="button" type="button" name="ShipToButton" value="Ship To Validate" onclick="myButtonFunt();">',
            )
        ),
    )
  • Hi Parag Mittal

    You code syntax is wrong.

    Do as Alan Apter suggested. It will work

    Let me know further help.

    Best Regards

    S Ramana Raju

Reply Children
No Data