SharePoint: How do I get the groups for the current user in Javascript or JQuery?
My current project requires me to identify the persona of the logged in user based on their membership of specific SharePoint groups. The first port of call is to extract all the groups for the current user and then work out what they can do. Sounds easy enough. I tried the following: function getUserGroups(success, failure) { var d = $.Deferred(); var ctx = SP.ClientContext.get_current(); var collGroup = ctx.get_web().get_siteGroups(); ctx.load(collGroup); ctx.load(collGroup, 'Include(Users)'); var currentUser = ctx.get_web().get_currentUser(); ctx.load(currentUser); var o = { d: d, collGroup: collGroup, currentUser: currentUser }; function onQuerySucceeded() { this.d.resolve(this.collGroup); this.d.resolve(this.currentUser); var data = { "collGroup": this.collGroup, "currentUser": this.currentUser }; //return success(this.collGroup); ret...