Tuesday, April 1, 2014

SugarCRM Cookbook: Retrieving User Roles

One of the challenges relating to the adoption of any new technology is understanding the manner in which one accomplishes equivalent tasks based on our experience with previous versions of the same technology. Sugar 7 is no exception to this rule, and this challenge is perhaps its biggest within the development community.

With that in mind, lets talk about a recent situation I came across that very much speaks to this point. In short, in the course of talking about the 7.x technology, the question arose of how one would go about retrieving a list of Roles assigned to a given user. Because we have to do this through a JavaScript based controller, techniques we might have used in the past are no longer applicable.

For the purposes of our example we will assume that we wish to retrieve the list of Roles assigned to the currently logged in user, in turn allowing us to see some details about the manner in which we interact with the current user, also a common need and one that also differs greatly. 

The following Gist will allow us to retrieve the Roles:

NOTE: Roles are only accessible to Admin level users and as such, the above code would only function if executed by a user with Admin privileges. In turn, it would also be best to specify a particular user ID rather than relying on the current user. 


  1. Hola Angel, sabe si existe alguna manera de gestionar en Roles las zolapas del ZuckerReports 2.1?

  2. Can we include this logic into a SugarLogic Expression in the javascript function?

    isMemberOfRole would be the new SugarLogic Expression

  3. Hola Ángel hay una manera de restringir una vista personalizada desde roles, o bien obtener los roles de un usuario, no importando si no es administrador, solamente los roles de ese usuario?


Your comments, feedback and suggestions are welcome, but please refrain from using offensive language and/or berating others. Thank you in advance.