In the old SugarCRM 6 world, if you wanted to create a custom action and call it directly it was as simple as creating a PHP file and dropping it in a directory. To illustrate, here is a simple example of an action called "HelloWorld". This exists in /custom/modules/Campaigns/HelloWorld.php:
To call the file you would simply pass the module and action in your URL: /index.php?module=Campaigns&action=HelloWorld.
In SugarCRM 7.* it is basically the same, but with one small change. You will need to add your action to the $action_file_map array for the module. When creating an installable package, you would add a definition to the action_file_map array in your manifest like:
After install, this file would then be found in /custom/Extension/modules/Campaigns/Ext/ActionFileMap/HelloWorld.php. If you are just testing things out and don't need to put it in your manifest yet, then you can simply drop the file in /modules/Campaigns/action_file_map.php. Remember, that file is not safe to use if you are creating a solution that you plan on distributing. Also, for some reason doing it in /custom, as you typically would do in that case and could in the past, no longer works.
Here is what the contents of HelloWorld.php would look like. Note that we have to now use lowercase for the action name. It will not work with camel case naming anymore.
To call this URL it would be /#bwc/index.php?module=Campaigns&action=helloworld.
NOTE: This only works with backwards compatible modules (BWC). We have not found a way yet to get this to work for the new framework.
Hopefully that helps someone else. We'll follow up when we find how this works for non-BWC modules. If you know the answer, please do share below and we'll add it to the post.
Edit: Thanks to Mike Solomon for pointing out that you can use the #bwc URL for non-BWC modules. This is a nice work around for directly calling an action for SugarCRM 7 modules. For example:
Drawing and Signature Field
Need a way to have customers sign a receipt or for project managers to draw a mock-up in real time right inside of Sugar? Add drawing fields to any SugarCRM module right from within Studio. Especially great when out in the field using a tablet. Signatures or drawings on the spot.
Trash Bin For SugarCRM
Recovering deleted data from CRM is now possible in the simplest manner with Trash Bin for SugarCRM. It can restore data from different modules that you or users delete from the system. Users can retrieve deleted data, easily from the Trash Bin for SugarCRM. It works for built-in as well as custom m...
A complete SugarCRM and DocuSign integration which allows us to quickly pull data from SugarCRM modules like Account, Contact, Lead, Prospect, User, Quote and Contract and then send them out for signature directly from SugarCRM. The signed document's fields are then returned to SugarCRM and attached...
- Show more addons