Search code examples
phpcrmsugarcrmsuitecrm

Call Custom Function on the Click of Menu Item


I have created one custom submenu inside the lead menu as "Process Leads" and now i want to call one custom function with the help of that menu item. i have defined it as:

$menu_item[]=Array("index.php?module=Leads&action=callCustom", "Process Leads", "");

Now the question is that where should i have to defined this callCustom function in the code?


Solution

  • index.php should never be changed in SuiteCRM - its a framework not a simple php script. So you have a proper way to do things.

    Now to the code.

    Actions are defined in the controller, in your case its the Lead module.

    What I usually do is go to modules/Leads folder and I copy controller.php to custom/modules/Leads.

    Edit the file and create your custom action like

    function action_customaction() {
                global $mod_string;
                if (isset($_REQUEST['yourParameter'])) {
               // Your awesome code here
                      }
    }
    

    Good luck with that