cd ../blog

SPImport + Custom User Fields = Value Cannot Be Null, Parameter Name: g

Tracking down a cryptic SPImport error caused by missing List and Mult attributes on custom User field definitions in elements.xml.

</>

A few days ago we had to export and import list items from a certain list, because we used item-level security and when your items go beyond 5k item count you hit the threshold.

Most of the advice you find on the internet is “increase the threshold.” Yes, you can do that — but ask yourself: why is it 5000?

It has to do with the SQL backend. SQL handles row locks up to a certain amount. More than 5000 and it does a lock on the entire SQL table. That’s not good.

So we redesigned the structure, used folders where security was common, and fixed the threshold issue. But we still needed to move the existing items to the right folders.

Because we didn’t want to just copy items and delete the source, we used SPExport and SPImport instead. The benefit: the entire item is exported, deleted, and imported at the correct location — including its original ID. Keeping the ID was critical since this was a production environment with emails and lookups already pointing to those items.

The Error

It didn’t take long before we hit our first error:

Value cannot be null. Parameter name: g

After searching and using Reflector to dig into the SharePoint binaries, we found that the import process checks whether a field contains a lookup to UserInfo. If it does, it expects certain attributes to be present.

The Cause

We had custom User fields defined in elements.xml like this:

<Field
  ID="{A77F7435-0F70-44CD-9D4A-C10520E2E0B2}"
  Description=""
  Name="LoginName"
  DisplayName="LoginName"
  StaticName="LoginName"
  Type="User"
  Group="Meligo"/>

This works fine in normal SharePoint usage — until you try to export/import items containing this field.

The Fix

Two attributes were missing from the field schema:

1. Add List="UserInfo"

Without this, the field is not recognized as a User field during import — it’s treated as a plain Lookup.

2. Add Mult="FALSE"

Only after adding both List="UserInfo" and Mult="FALSE" is the field correctly identified as a User field during SPImport.

The corrected field definition:

<Field
  ID="{A77F7435-0F70-44CD-9D4A-C10520E2E0B2}"
  Description=""
  Name="LoginName"
  DisplayName="LoginName"
  StaticName="LoginName"
  Type="User"
  List="UserInfo"
  Mult="FALSE"
  Group="Meligo"/>

After pushing the updated field schema to all list fields, the import worked perfectly.

Bonus: “Cannot Find User” Warning

If you get the error/warning “cannot find user with {ID}” during import, your user isn’t listed in the UserInfo list.

You can access the User Information List (admin only) via:

http://YourSiteUrl/_catalogs/users/simple.aspx

Good luck hunting! 😊