I have a site column defined in an Elements.xml file in Visual Studio. The SharePoint project this is in does all sorts of initial configuration on the website. I need to set the UserSelectionScope to be a certain group, however this won't work unless the group already exists and I know the ID, which I do not because the group in question is create in code in the feature event handler.

Essentially, I am trying to capture all of the initial setup and configuration of this SharePoint site in a single feature/solution that doesn't require manual intermediate steps.

Does anyone know if it's possible to set the UserSelectionScope by doing some kind of lookup by name? If not, does anyone have any suggestions?

Thanks in advance.


Does this help?


Gets the group by name, and then calls the Id.

| improve this answer | |
  • I was afraid this might be the only solution. Very poor maintainability having half of a site column being made in XML and half in code. Gotta love SharePoint... – MgSam Jul 27 '12 at 16:49
  • Yeah, I've run into a similar situation before. Getting Guids dynamically is clunky, but achievable. – RJ Cuthbertson Jul 27 '12 at 17:18

A quick one I thought of:

Why don't you only create the Field in the Elements.xml and then set the UserSelectionScope property of that field in the Event Handler after the group is created?

You can use the following property from the Object Model: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfielduser.selectiongroup.aspx

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.