Monday, August 03, 2009

Create custom groups in SharePoint

To create custom groups in SharePoint, use the SPWeb SiteGroups collection.

web.SiteGroups.Add(groupName, owner, member, description)

Groups created using code will not automatically appear in left navigation. For them to appear there, the groups need to be associated with web. The code to this is

web.Properties["vti_associategroups"] = web.Properties["vti_associategroups"] + “;” +  web.SiteGroups[groupName].ID.ToString();

web.Properties.Update();

0 comments: