A common Sugar 7.x Dashlet Gotcha

Matthew Marum —  March 9, 2015 — 5 Comments

Sugar 7 Dashlets

As you may know Dashboards and Dashlets are some of Sugar 7’s most popular front-end features. Customizable Dashboards empower users with the ability to customize the contextual intelligence that gets delivered to them by their CRM within every single view of the application.  For Sugar Developers, Dashlets allow us to deliver contextual intelligence (including integrations) to our end users in a well encapsulated component and a consistent pattern.

A Dashlet Gotcha!

Since Sugar 7 Dashlets are just Sidecar views, there is metadata that you need to manage.  So one of the biggest things you’ll want to remember when working with Dashlet metadata is that Dashlet metadata gets copied into the dashboards table. If you change the .php metadata file for the dashlet, you need to make sure that you delete the old dashlet definition from the database for the module/view you are testing it on.  Otherwise no matter how many times you clear your cache, restart your computer, or throw your mouse, that dashlet won’t be doing what you’re expecting it to do!

The simple way

The simplest way to do that is to delete the dashlet using the Sugar user interface.

Removing a Dashlet

Removing a Dashlet

Once you’ve done that, you can edit your dashboard to add your dashlet over again and this time it will include the updated metadata.

The automated way

If you are doing a lot of dashlet development and are interested in a way to automate this process a bit, then you can create a dashboard cleanup SQL script that goes into the dashboards table and deletes the row for your test dashboard.

See below as an example of working with a Dashboard entry in Sugar 7.5.0 via the Sugar database.

SQL query: SELECT name, dashboard_module, dashboard_type, metadata FROM `dashboards` WHERE name = ‘Test Dashboard’;

name dashboard_module dashboard_type metadata
Test Dashboard Accounts dashboard {
“components”: [
{
“rows”: [
[
{
“view”: {
“type”: “dashablelist”,
“label”: “Test Dashlet”,
“display_columns”: [
“name”,
“billing_address_country”,
“billing_address_city”
],
“module”: “Accounts”,
“skipFetch”: true,
“last_state”: {
“id”: “dashable-list”
},
“componentType”: “view”,
“intelligent”: “0”,
“limit”: 5,
“filter_id”: “assigned_to_me”
},
“context”: {
“module”: “Accounts”,
“link”: null
},
“width”: 12
}
]
],
“width”: 12
}
]
}

Once you’ve located your row, you can delete it easily.

SQL query:  DELETE FROM `dashboards` WHERE name = ‘Test Dashboard’;

1 row deleted.

Matthew Marum

Posts

Matt is the Director of Developer Advocacy for SugarCRM. Previously he was an Engineer on Sugar 7 and a Solutions Architect for the OEM program. He is also an avid trail runner, Boston Marathon qualifier and a karaoke aficionado.

5 responses to A common Sugar 7.x Dashlet Gotcha

  1. 

    Can you put in a feature request so that Quick Repair and Rebuild will do this for you?

    • 
      Matthew Marum March 9, 2015 at 2:06 pm

      I can, though there is a bit of a challenge. Saying that Dashlet metadata is “cached” probably wasn’t the right word. It’s really just copied in as part of the dashboard definition. So the issue with doing an automated repair that clears this stuff out is that you don’t have a foolproof way to differentiate a “test” dashboard from the real ones your users have created. That’s really the bigger problem. I’ll create a feature request to look at ways to enhance the whole process.

  2. 

    If you delete the whole dashboard record you destroy perhaps the whole work you did for this dashboard which can be very complicated.
    Wouldn’t it be better just to delete the one dashlet from the dasboard on the UI and add it again?

Trackbacks and Pingbacks:

  1. Creating a “Hello World” Dashlet for Sugar 7 « Sugar Developer Blog – SugarCRM - June 22, 2015

    […] to anyone about to embark on the Dashlet development journey.  We recently featured a post on a common Sugar 7.x dashlet gotcha.  Basically, dashlet metadata gets copied into database when you add a dashlet to a dashboard. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s