I am developing an app, and I am trying to test if a user is a member of a group. I have tested that the group can be seen in the settings of the sharepoint site - so the group definitely exists.
I have tried usnig cleint context and host context. But both result in an error "Group Can not be found".
My code in my Sharepoint Hosted App is as follows:
var context = SP.ClientContext.get_current(); var user = context.get_web().get_currentUser(); var webContext = context.get_web(); var allGroups = webContext.get_siteGroups(); var mygroup = allGroups.getByName('my group'); $(document).ready(function () { loadgroups(); } function loadgroups(){ context.load(user); context.load(allGroups); context.load(mygroup); context.executeQueryAsync(onSuccess, onFail); }
*Error* groups can not be foudn