Imagine the following scenario: You have created custom SPField for your Content Type. SPField is of type "User", i.e., a PeopleEditor field where you can select a one or several Active Directory users or groups.
In my case the SPField definition is something like this:
<Field ID="{UNIQUE_GUID}"
Name="ProjectOwner"
Group="MyGroup"
Type="User"
DisplayName="Project Owner"
SourceID="http://schemas.microsoft.com/sharepoint/v3/fields"
StaticName="ProjectOwner"
Required="FALSE">
</Field>
Then you do a STSADM EXPORT and IMPORT for the SPWeb using Content Type using this SPField.
STSADM EXPORT succeeds, but STSADM IMPORT throws error:
Progress: Importing ListItem /a/windows-hardening/Pages?id=1.
FatalError: Value cannot be null.
Parameter name: g
at System.Guid..ctor(String g)
at Microsoft.SharePoint.Deployment.ListItemSerializer.UpdateFieldData(SPListItem listItem, ImportObjectManager objectManager, Guid docId, String fieldName, String value, String value2, Guid gFieldId, Boolean& bCreated, Dictionary`2 brokenFields)
at Microsoft.SharePoint.Deployment.ListItemSerializer.UpdateFieldData(SPListItem listItem, Guid docId, Boolean& bCreated, SPContentTypeId contentTypeId, ImportObjectManager objectManager, Object data)
at Microsoft.SharePoint.Deployment.ListItemSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType,Boolean isChildObject)
at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
at Microsoft.SharePoint.Deployment.SPImport.Run()
Thoughts:
If you use -nofilecompression parameter when exporting and importing using STSADM, you can look at the exported Manifest.xml and see the difference between fields that have List="UserInfo" and the ones that don't.
OOB field PublishingContact value is exported like this:
while custom ProjectOwner field value without List="UserInfo" in its definition is exported like this:
<Field Name="ProjectOwner"
You can see that the custom field contains the GUID of the list where the item is located in, while the OOB field contains clear reference to UserInfo list.
Solution:
First of all, remember to always include List="UserInfo" when defining SPFields of type "User", like this:
<Field ID="{UNIQUE_GUID}"
Name="ProjectOwner"
Group="MyGroup"
Type="User"
DisplayName="Project Owner"
SourceID="http://schemas.microsoft.com/sharepoint/v3/fields"
StaticName="ProjectOwner"
Required="FALSE"
List="UserInfo">
</Field>
If you realize this requirement too late, you can modify the exported Manifest.xml and replace the values of the fields affected from:
<Field Name="ProjectManager" Value="2;GUID_OF_PAGES_LIST" FieldId="6677cf63-f416-4e1e-9e6e-f77f243ef4a6" </>
to
<Field Name="ProjectManager" Value="2;UserInfo" FieldId="6677cf63-f416-4e1e-9e6e-f77f243ef4a6"</>
and import after that.
In addition you need to have custom application that enumerates all existing items and fix field definition on them using API.