Skip navigation
All Places > Developer > Blog > 2015 > March
2015
If you've browsed the Sugar 7 JavaScript codebase much then you'll notice that we use Underscore.js all over the place. Use of _.each, _.bind, _.debounce, _.filter, and more are littered throughout the Sugar 7 codebase.  It's not uncommon to see multiple usages of it on the same line of code.
 this.resize = _.bind(_.debounce(this.resize, 200), this);

 

In order to get a quick estimate of how often Underscore is used, you can do a quick search for "_." within JavaScript sources.  The Sugar 7.5 JavaScript codebase turns up 5,976 uses of Underscore.js!

 

We love Underscore for a couple different reasons.  First off, it helps make our JavaScript code much more readable than if we used vanilla JavaScript everywhere.  Secondly, there's some handy utilities in Underscore that can be expertly applied to improve Sugar 7 application performance.

 

Read below to learn how several Underscore.js Function utilities can be used to improve performance and responsiveness of your apps.

 

Lets start with a real example where we used _.debounce() to improve performance for end users of Sugar 7.5.

 

filter-quicksearch.js

    ({
...

/**
     * Fire quick search
     * @param {Event} e
*/
    throttledSearch: _.debounce(function(e) {
var newSearch = this.$el.val();
if(this.currentSearch !== newSearch) {
this.currentSearch = newSearch;
this.layout.trigger('filter:apply', newSearch);
        }
    }, 400),

...
    })

 

What debounce does is postpone execution of a function until after an elapsed time has passed since a function was last called.  In this case, the throttledSearch function gets called every time there is a key press in a Sugar 7 Quick Search input box.  Without debounce, if a user was trying to type a search term like "Acme" then we'd be triggering search for "A", "Ac", "Acm", and then "Acme".  This creates a load on the server and gives impression that the search feature isn't working properly because of the delay in displaying the final search results due to all the previous unnecessary requests.

 

Using _.debounce(fn, 400) means that searches will not be triggered until the user pauses typing for almost half a second (400 milliseconds)._.throttle() is similar except that it triggers the wrapped function at most once for every given time interval.  This makes it useful to implement some sort of rate limiting if you expect many requests to occur faster than they could be reasonably handled._.defer() is my favorite Underscore function.  It allows you to put an operation that doesn't need to be run immediately on the JavaScript event queue where it will be executed later after any pending UI events.  This improves user experience of the app since it shortens long running JavaScript operations that would otherwise block the user interface and make the web app appear unresponsive.  If you want to pop up an informational dialog or re-render a view - do you really need to do it synchronously?  Probably not.  A momentary delay in favor of a responsive user interface is a very good trade-off.

 

There's a lot more to Underscore than what I've described here.  I hope you take the time to explore it and incorporate usage of it into your Sugar 7 apps and customizations!

This would be a good post to bookmark!

 

Francesca, one of our Sugar Community members, has a great post on the Sugar Community where she lists some of her favorite Sugar 7 resources and asks the community to list their own.  It has become one of our most active conversation threads in the Sugar Community.

 

In the same spirit, I wanted to summarize the Sugar 7 resources that the community shared in that thread including a few of my own. Let me know if I'm missing anything below!

 

Live Training

Sugar Administration Essentials (SugarCRM)Sugar Developer Essentials (SugarCRM)Hot Topic Webinars (SugarCRM)SugarCRM Power Hour (Ticomix)

 

FAQs

Sugar Developer Community (SugarCRM)Sugar Knowledge Base (SugarCRM)

 

Videos

Self Paced Sugar Administrator TrainingSelf Paced Sugar Developer TrainingLearn jQuery in 30 Days (Tutsplus)Backbone JS (Tutsplus) Hot Topic Webinar Recordings (SugarCRM)

 

Guides

Sugar Developer Guide (SugarCRM)Sugar 6 to 7 Upgrade Training (SugarCRM)Dependent Fields Guide (Atcore Systems)

 

Sugar 7 Tooling

Sugar Developer Tools (SugarCRM)

 

Grunt

Stuart Fyfe's Sugar 7 Development Grunt.js setup

 

Java Sugar 7 Clients

Antonio Musarra's Sugar 7 REST client

 

PHP Sugar 7 Clients

Sean Pinegar's Sugar 7 REST client

 

Docker

Sugar Docker Example Stack (Synolia)Sugar Docker Performance Test Stack (Synolia)

 

Other Blogs

SugarOutfittersInsightfulCRMShane DowlingAngel MaganaUrdvha TechAntonio MusarraJeff Bickart
Someone recently asked Sugar Engineering the following question.
Suppose I have a webpage or web app that I am accessing from a mobile device, e.g. Safari on iPhone or Chrome on Android. Is it possible for me to create a link on that page into the SugarCRM Mobile application installed on my mobile device? Say for example I want it to open my mobile app to a specific Contact record.

 

SugarCRM Mobile does support this kind of functionality.  You can embed a link that looks as follows:

<a href="sugarcrm:///Configure?page=Contacts%2F_RECORD_ID>" View Contact </a>

 

Where "_RECORD_ID" is replaced with the full Contact ID.  Basically, the page parameter is the URL encoded route into the SugarCRM Mobile application.  To find out other supported routes, you can navigate around the web version (http://your_sugar_instance/mobile/) of the mobile app on any Sugar 7 instance.  The part of URL after hash sign will be the route you can use in "sugarcrm://" links.

 

This will have you creating some slick integrations with the SugarCRM Mobile app in no time!

Greetings Sugar Developers!

 

Are you coming to SugarCon this year?  We hope so!  But even if you are not, we'd still love to hear from you.

 

We would like to gather information from as many Sugar Developers as possible to make sure this year's UnCon caters to the needs of the Sugar Developer community... in more ways than one!  This feedback is essential to us as we plan for UnCon.  Most importantly, this survey is how we are gathering preliminary feedback on discussion topics and exercises that Sugar Developers want to see at UnCon.  So please feel free to share as much or as little information as you'd like.

 

To fill out the Developer Survey, please visit the UnCon minisite and click on the big green link on the right that says "Developer Survey".

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.

 

https://github.com/sugarcrm/devdocs/blob/master/Cookbook/building-a-hello-world-dashlet.md#dashlet-gotchasA 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.

 



 

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';
namedashboard_moduledashboard_typemetadata
Test DashboardAccountsdashboard{

 

"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.

It's time to let some of your hard work shine!  Martin Schneider just posted this today on our corporate blog.  I hope everyone can make it to SugarCon but even if you can't, you can still submit your sweet Sugar apps in the App Throwdown.  See details below.
SugarCon is just around the corner – and that means it is also time for another round of the SugarCon App Throwdown! The App Throwdown – always an attendee favorite – is a showcase of some of the coolest, most useful, and most innovative extensions of the Sugar platform. The fun, sometimes manic, atmosphere of the final judging session at SugarCon not only promises to entertain, but also give Sugar users some great tools to advance their own CRM initiatives.

 

While App Throwdown is always a blast – we wanted to make it even better this year. How? Well, for starters, we’ve opened up the submission eligibility to EVERYONE! That’s right – anyone who wants to submit an extension, connector, custom app integrated to Sugar, etc. can apply. Simply fill out this ONLINE FORM to be part of the processes.

 

Submissions will be accepted until March 27! So get your submission ready – all you need is a cool app/connector/customization, a short video of your app in action, and a completed form to enter!

 

Also, we have created some categories to help guide your submissions, and the category winners will be the ones to battle it out for “Best in Show” on the main SugarCon stage in April.

 

This years categories include:

CategoryDescription
MobileHelp your customers see i2i, wherever they are. This category will be judged on the best mobile customization, or mobile extension of Sugar in marketing, field sales, field service or other customer-facing scenarios.
Best Seamless IntegrationSugar provides virtually limitless ways of integrating with virtually limitless apps and data sources. This category will focus on applications that follow the best practices of our UI/UX and show creative use of the Intelligence Panel, Dashlets, Activity Streams, and other key areas of the Sugar UX best in class user interface.
Data, Information, & AnalyticsGetting the right information at the right time is a critical part of creating extraordinary customer relationships. Understanding business insights is an important tool for optimizing your selling and go-to-market strategy. Entries in this category will be judged on how they help Sugar users make better decisions and execute faster based on having better information at their fingertips.
Customer Experience and EngagementThis category will look at integrations and customizations that optimize the customer experience and increase levels of engagement. These can include workflow-based customizations and extensions to better align with the customer journey; embedded call center or other real-time employee-to-customer communications; or tools to help agents close more deals or resolve more cases faster.
Beyond CRMThe openness of the Sugar platform means that developers and users’ only limits are their imaginations.  Entries in this category will focus on the “edge cases” of CRM. So, if your application interfaces with the real world through the “Internet of Things”, or you’ve added game mechanics to motivate the right behavior, or tied into today’s powerful social tools, this category is for you!

 

The judging process this year will be a bit different as well. An all-star panel of SugarCRM staff and some special industry influencers and observers will judge all submissions to determine the category winners. These will be announced here on the blog in early April.

 

At SugarCon, the category winners will compete on stage for the “Best in Show” award – in front of an expert panel of SugarCRM executives including CEO Larry Augustin, and some guest industry influencers. But as in past years – the audience will vote on the category winner they think deserves to be Best in Show!

 

So, all you Sugar partners, developers, tech-savvy customers with a cool custom module or integration – we invite you to submit ASAP and join us in making the 2015 App Throwdown the best yet!

Below is a message from Ticomix, an Advanced SugarCRM Partner, about a monthly webinar series focused on the Sugar Developer/Admin hosted by one of our most active Sugar Developer community members Jeff Bickart.
SugarCRM Power Hour with Jeff BickartWebinar Series Overview:

 

We know how hard it can be to get the dedicated, interactive support you need, so we’re here to offer help. Each month, we’ll deliver a unique perspective to the common (and sometimes uncommon), everyday technical issues you face with the administration of SugarCRM. Each hour-long webinar will contain valuable information plus a live Q&A session to answer any burning questions you have. The initial schedule of topics is below.

 

The first webinar is happening March 11th @ 1:00PM ET. In the webinar, Jeff will unveil helpful hints for setting up your development environment and installing Sugar. Even if you’ve already setup your Sugar environment, you’ll find valuable tips for optimizing your install of Sugar.

 

Also, Jeff welcomes questions prior to the webinar. Click here to access Jeff’s webinar question form »Click here to register for one or all webinars »UPCOMING POWER HOUR SCHEDULE (all webinars begin at 1:00PM US Eastern Time):

  • March 11th: How to Set Up Your Development Environment & Install Sugar
  • April 8th: Building Custom Dashlets
  • May 13th: Using the SugarJobQueue & the SugarCRM Directory Structure
  • June 10th: Workflows, LogicHooks & Deploying Packages
  • July 8th: Layouts, Views and Building a Wizard
About Jeff:

 

Jeff Bickart, CRM Evangelist at Ticomix, has been developing in Sugar since 2004 (the same year SugarCRM was founded) and is one of the foremost experts in SugarCRM development. He writes a popular SugarCRM Developers Blog (SugarCRM: Developers’ Guide), is a frequent contributor on the Sugar community forums, and has made vast contributions towards Sugar’s code base. Jeff invites you to connect with him in several ways:

 

Twitter: @bickart

 

LinkedIn: https://www.linkedin.com/in/bickart

 

Blog:  http://sugarcrm-dev.blogspot.com/