SugarCRM - Search for records related to the current record
Sun 20 April 2014
Say you have two modules in Sugar: Animals and Ringmasters and they aren't directly related via a standard relationship but they are related through some convoluted means. Now, imagine if you want to override the SugarCRM search to allow you to search for all Animals indirectly related to a Ringmaster, I've written about how to do something similar recently. Conversely, you want to search for all Animals related to a Ringmaster you're currently viewing. It's not a link that exists in Sugar so you can directly see a Dashlet and you don't want to build anything from scratch so that's going to take effort.
What you could do, is create a link on the action drop-down while viewing the Ringmaster that linked you to a search that would call animals supplying the Ringmaster's id as the argument.
This is based on the previous tutorial I've shared.
- Firstly add a new logic hook in custom/modules/RingMasterModule/logic_hooks.php
$hook_array['after_ui_frame'] = Array(2, 'Custom Ring Master Buttons', 'custom/modules/RingMasterModule/CustomButtons.php ','RingMasterButtons', 'add');
- Then add the custom buttons class in custom/modules/RingMasterModule/CustomButtons.php
Quick Repair and Rebuild for good measure. This should add a hidden form that will be called when the user clicks the Ring Master Animals.