How to get group object from group name something like this.
var groupCollection = clientContext.get_web().get_siteGroups();
group = groupCollection.getByName("Group Name");
Above code will work in SP2013. But not in SP2010.
You could do something like this:
var groupCollection = clientContext.get_web().get_siteGroups();
var myGroupName = "Group Name";
var myGroup = null;
clientContext.load(groupCollection);
clientContext.executeQueryAsync(function(){
var groupEnumerator = groupCollection.getEnumerator();
while(groupEnumerator.moveNext()){
var currentGroup = groupEnumerator.get_current();
if (currentGroup.get_title() == myGroupName)
{
myGroup = currentGroup;
break;
}
}
},
function(sender,args){
console.log(args.get_message());
}
);
After this code runs, you should have the details of your group in the myGroup
variable.