|I've built a feature for our training department, which up until today has worked as intended. Today wrote some code in the feature activation that will add a new SharePoint group called 'Travel Plaza Managers' (Travel Plaza is a department within our organization that runs our gas stations).
On the feature activation I first run a function called 'checkForGroup', which checks to see if the group has already been created on the site. Here is the code for that group:
Public Function checkForGroup(ByVal groupName As String, ByVal web As SPWeb) As Boolean
Dim group As SPGroup = Nothing
group = web.Groups(groupName)
Catch ex As Exception
If Not group Is Nothing Then
If this function returns 'False' then I call another function called 'CreateTPManagersGroup', which runs this code:
Public Sub CreateTPManagersGroup(ByVal web As SPWeb)
Dim owner As SPUser = web.SiteAdministrators("username")
Dim member As SPMember = web.SiteAdministrators("username")
Dim groups As SPGroupCollection = web.SiteGroups
groups.Add("TP Managers", member, owner, "These are the current Travel Plaza Managers of the Choctaw Nation")
Dim newSPGroup As SPGroup = groups("TP Managers")
Dim role As SPRoleDefinition = web.RoleDefinitions("Read")
Dim roleAssignment As SPRoleAssignment = New SPRoleAssignment(newSPGroup)
So, the first time I ran this, the activation ran fine, but when I went to see if the group had been created the group name wasn't there. Figured I may have done something like not actually deploy the current version of the feature, so I did another deploy from Visual Studio and got the message saying that the group name had already been used.
Did a debug on the feature activation and each time 'checkForGroup' returns 'False', but I still get the same message that the group name has already been used. I can't remove the group because it doesn't show up on the website, so what am I to do?
modified 10-Apr-14 16:18pm.
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.