Matt Marum

Sugar 7.5 Metadata Diving for Smarter Integrations

Blog Post created by Matt Marum Employee on Apr 20, 2015
For Sugar 7.7 and later versions, you can access metadata from within the Sidecar clients using 


Many Sugar Developers are looking to build intelligent API integrations with Sugar that goes beyond Create-Read-Update-Delete (CRUD) operations.  The key to building robust and intelligent API integrations with Sugar is held within the Sugar Metadata.


Sometime it is interesting to understand what dependent dropdowns exist on any given Sugar module.  A common use case would be to display appropriate UI with properly populated drop down lists to end users of an integration with Sugar 7.



If you don't have the dependent dropdown formula then you are stuck guessing at what options are available or showing the user the full list of options when only a subset of them are valid choices.  The key for addressing these user experience concerns and for anybody else wanting to take their Sugar API integration to the next level is the Sugar Metadata API.


If you are familiar with Sugar 7 then you probably know that we use the v10 REST API to drive the Sidecar framework used in our web, mobile, and portal clients.  Sugar Logic formulas are configured in Sugar Metadata which means the Metadata API is how the Sidecar framework is made aware of them.



If you are building a Sidecar client then Sugar Logic gets handled for you automatically - but otherwise you can mine the metadata to find the tools you need.


For convenience, you can browse the entire Sugar metadata cache for any user using your browser's dev tools (such as Chrome Dev Tools used in example below).  Just log into Sugar 7 as your target user, open your javascript console, and run the commands below.  This will return the current metadata payload that was retrieved from server via Metadata API.

SUGAR.App.metadata._dev_data; // replace _dev_data with get() in Sugar 7.7 and later


In this example, the full options list of display values used is available within app_list_strings.car_list.



This can be compared with the dependent dropdown formula found in the Opportunity Record view metadata.  Sugar Logic defines dependencies between fields that affects their presentation to end users.  So you'll find this information mixed into the View metadata in the dependencies hash.




This should give them all the information they need to intelligently work with this dependent dropdown field.  Now they can decide how they want to handle these in their integration.

A quick note about programming against Metadata API


The Sugar metadata payload is pretty large so you'll want to cache it as much as possible.  It's a good idea to only retrieve the metadata for modules you care about to limit the size of the request.  You should track the metadata hash value which can be used to reload metadata only when it changes.  Again, if your code is running within Sugar 7 (and therefore using the Sidecar framework) then metadata is refreshed automatically as needed - so you can always assume the metadata you find there is up to date.