I'm trying to remove a user from a SharePoint 2010 group using JSOM, but not having much luck. I've been trying to adapt the script on this page - http://www.c-sharpcorner.com/Blogs/9650/add-and-remove-user-into-sharepoint-group-using-client-objec.aspx
When I run my code, I get an error about line 8 - "Unexpected token =>" I see other examples with that notation. What's wrong with it?
function removeFromGroup(siteURL) {
var client = new ClientContext(siteURL);
client.ExecuteQuery();
var website = client.Web;
client.Load(website, w => w.AllProperties, w => w.SiteGroups, w => w.SiteUserInfoList, w => w.Webs,w => w.Title);
client.ExecuteQuery();
var groupCollection = website.SiteGroups;
client.Load(groupCollection, groups => groups.Include(grps => grps.Users, grps => grps.Title));
client.ExecuteQuery();
var user;
foreach (Group group in groupCollection)
{
if (group.Title.Equals("Test"))
{
var userInfo = new UserCreationInformation();
userInfo.LoginName = "<I put the AD username here>";
user = group.Users.GetByLoginName("<I put the AD username here>");
group.Users.Remove(user);
group.Update();
website.Update();
client.ExecuteQuery();
}
}
}