Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Does this help?

http://jankrogh.blogspot.com/2012/03/setting-userselectionscope-of-user.html

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

share|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
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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