Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm trying to accomplish the same thing in a feature activated event. I have found how to create the group and how to access these settings in the object model. You can use my example below. The problem is, my changes to these boolean properties of the SPGroup don't take, despite calling SPGroup.Update(). The SPGroup created still uses the default settings (membership requests are turned off).</p> <pre><code>public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = (SPSite)properties.Feature.Parent; { using (SPWeb web = site.RootWeb) { SPGroupCollection collGroups = web.SiteGroups; SPUser user = web.EnsureUser("DOMAIN\\username"); collGroups.Add("MySPGroupName", user, user, "MySPGroupDescription"); if (!web.AssociatedGroups.Contains(collGroups["MySPGroupName"])) { web.AssociatedGroups.Add(collGroups["MySPGroupName"]); } SPRoleAssignment assignment = new SPRoleAssignment(collGroups["MySPGroupName"]); SPRoleDefinition def = web.RoleDefinitions.GetByType(SPRoleType.Contributor); assignment.RoleDefinitionBindings.Add(def); web.RoleAssignments.Add(assignment); web.Update(); collGroups["MySPGroupName"].AllowMembersEditMembership = true; collGroups["MySPGroupName"].AllowRequestToJoinLeave = true; collGroups["MySPGroupName"].OnlyAllowMembersViewMembership = false; string emailForRequests = "username@domain.com"; if (!String.IsNullOrEmpty(user.Email)) emailForRequests = user.Email; collGroups["MySPGroupName"].RequestToJoinLeaveEmailSetting = emailForRequests; collGroups["MySPGroupName"].Update(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload