If you use a field user in your lists which is filtered by using SharePoint group filtering and you intend to move your application from one environment to another through the content migration API, this post is for you!
First, a quick reminder on how to filter the users on the basis of a group:
In the definition of the list, click the name of the User column. Then, in the Properties window, just select the group used to filter users.
What happened internally? The identifier of the selected group is stored in a property of the field. This is SPFieldUser.SelectionGroup property that receives and returns an integer as MSDN describe it: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfielduser.selectiongroup.aspx.
This identifier (424 in our example) is in the URL when you change the group members:
At this time, there is no problem.
A problem can occur when, using the content migration through API STSADM (STSADM - o export) or a custom tool (SP RAD Studio for example) , we export this site and then import it to another environment. Surprise! It turns out that the selected group for the filter does not match what we expected.
What has happened? The answer is simple. Only a identifier as an integer is used as we have seen. Looking at the package generated by an operation export, one might think that the import will no problem since found in the file Usergroup. xml as we found this information: <Group Id="424" Name="GroupName" [...]> but it is not the case.
It will be necessary to manually edit this filter after migration. To do this, just use the web interface ... if we have the rights. Otherwise, one possible solution is to use STSADM extensions. I use this solution for performing all operations using a single script.
This operation takes parameter the name of a SharePoint group (not an ID as we didnot know it): stsadm -o setfieldproperties -url <SiteUrl> -list <Listname> -field <Fieldname> -userfieldgroupfilter <GroupName>
This extension is part of the extensions migration extensions available on CodePlex (http://www.codeplex.com/migrationstsadmext).