is there a way I can use the below with something like getByName(thisGroup), instead of getById(10) in SP 2010 jsom:
function setSomeUsers(dataObj, projGroup) {
var clientContext = new SP.ClientContext.get_current();
var collGroup = clientContext.get_web().get_siteGroups();
//instead of this:
var oGroup = collGroup.getById(10);
// something like the below
// var oGroup = collGroup.getByName(projGroup);
var userCreationInfo = new SP.UserCreationInformation();
userCreationInfo.set_email(dataObj.userEmail);
userCreationInfo.set_loginName(dataObj.userLogin);
userCreationInfo.set_title(dataObj.userTitle);
this.oUser = oGroup.get_users().add(userCreationInfo);
clientContext.load(oUser);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onSetAdminsQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onSetAdminsQuerySucceeded() {
alert(this.oUser.get_title() + " added.");
}
// plus the failed here
so if the above isn't possible, is there a way to get the name and id out of get_sitegroups()
callback?
appreciated as always!