4

I need to get the security roles which are associated to the current user in CRM Online. How do I do this using JavaScript?

Daryl
  • 18,592
  • 9
  • 78
  • 145
V.V
  • 875
  • 3
  • 25
  • 54

1 Answers1

6

Use the Xrm.Page.context.getUserRoles() function.

Daryl
  • 18,592
  • 9
  • 78
  • 145
  • If i use this I can get the ID of the userrole which means i get the number not a name of the user role. – V.V May 15 '13 at 02:46
  • @V.V you can always perform an ODATA call to get the id. Using this blog, you can see what entities you'll need to interact with, but since it's for C#, you won't be able to use it as is: http://arvindcsit.wordpress.com/crm-learning/retrieve-the-roles-for-a-user/ – Daryl May 15 '13 at 02:51
  • Thanks for your reply.Is there any possible way to do this from script? – V.V May 15 '13 at 02:54
  • Yes, the easiest way is with an OData call. If you've never made an OData call before in CRM, consider asking a new question, "How do I get the Id of a role by role namevia JavaScript in CRM 2011? – Daryl May 15 '13 at 10:51