This post is about how to create a new dashlet for activity modules (Calls, Tasks, and Meetings) that will show a preview of the parent record for the activity in record view.
There are four files required for this customization. Three are related to the dashlet and one is a language file.
One important note for Sugar 7 dashlets is the directory and the .php, .js, and .hbs files must have the same name. So if you had a dashlet called hello-world you would need:
- Directory hello-world
Since this dashlet will be used for multiple modules the dashlet files are located in ‘custom/clients/base/views/’.
The php file defines the dashlet filters. We want the dashlet to be available in the Calls, Tasks, and Meetings modules Record View so we add definition in the dashlet filter.
The handlebars template is where the dashlet view is set. In this instance Accounts and Opportunities as those are the primary modules used. This template shows some custom fields for this instance so you should remove those if you use this. I also already have a logic hook that displays the parent phone number on the call record. If that isn’t the case it would be very beneficial to add that to the template. Remember you’ll have to change depending on the parent module type.
Lastly we need to add the language file that will update the dashlet name in when going to add it along with the description.
Something I didn’t do but that would add some nice functionality would be to do another api call to try to get the notes associated with the parent module. I decided not to do this because the dashlet was intended to give a quick preview. I added the button to open the record at the bottom of the dashlet if the user needs more information. It would be interesting to see that similar to the preview from list view shows the related records in the intelligence pane.
Hope this slightly more advanced dashlet (compared to the proof of concept ones) helps someone if they want to create a dashlet like this or their own dashlet.