Editor’s Note: This blog post comes from an excellent forums thread created by community member Francescas. While often I quote or reference blog posts and provide solutions, having one this spot on and very upgrade-safe is one our whole developer community should build from, so I felt re-posting it here will bring that attention to it ( with some minor editiorial and code changes for clarity and to reflect best practices ).
Do you have any great tips or code like this? If so, I invite you to be a guest blogger on this blog; just email me at firstname.lastname@example.org for more information. And big thanks to Francescas for this spot on forums thread!
We wanted to get something on Cases Dashlets and Cases List view to make certain statuses/conditions stand out.
Here is what we achieved:
And Here is how I did it – It may not be the best way, but it works:
I added a non-db field to Cases, this will contain my bullet image in <mysugar>/custom/Extension/modules/Cases/Ext/Vardefs/custom_var.ext.php
Ran Repair Rebuild.
In <mysugar>/custom/modules/Cases/metadata/listviewdefs.php, I added customCode on the Status field to display the non-db field contents next to the status in the list view:
I then added a process_record logic_hook in <mysugar>/custom/Extension/modules/Cases/Ext/LogicHooks/formatCaseField.php to set the non-db field based on values for each record. This logic hook executes for each row of the list view (which is also used for the dashlet)
The conditional formatting script sets the non-db field for each row. The “title” in the img makes it so that when the user hovers on the colored bullet they get an explanation of what that color in, just in case they forgot or don’t know.
NOTE: I had to use a new Cases bean because the $bean in the logic hook only contains the fields that are displayed in the listviewdefs.php, not hidden fields like my
if I used $bean->case_number_of_interactions_c then I would have gotten NULL on all values because that field is not included in my list view. By using the $bean id to retrieve a copy of the full bean (which I called $c) I can use any field in the cases or cases_cstm table
For the images in <mysugar>/custom/themes, I created a bullets subidrectory and loaded some bullet images
To get the same bullets in the Dashlet I copied the My Cases Dashlet directory to
and added my non-db column with no title (so it takes up less space) and not sortable, I didn’t want the little arrows to appear either and it wouldn’t make sense to sort by an image
Admin->Repair->Rebuild Sugar Dashlets
Admin->Repair> Quick Repair/Rebuild for good measure