views:

65

answers:

1

I'm trying to insert a bunch of data into a SharePoint list. The List is a custom list based on the Item content type with a couple of custom columns, Contact and Code, where code is a custom field type based on SPFieldText.

I am exploring the list using PowerShell 2.0, and enumerating the fields of the list (or any given list item) causes an exception as follows:

PS C:\> $list.Fields

# output of a few fields

An error occurred while enumerating through a collection: Exception has been thrown by the target of an i
nvocation..
At line:1 char:7
+ $list. <<<< Fields
    + CategoryInfo          : InvalidOperation: (Microsoft.Share...on+SPEnumerator:SPEnumerator) [], Run 
   timeException
    + FullyQualifiedErrorId : BadEnumeration

I don't really get why this is the case - nothing on the site seems to be broken, and SharePoint Manager is able to enumerate all the fields and list items without a problem. Further, when I try to grab a single list item and inspect its fields, I get null from my custom field:

PS C:\> $list.Items[0]["Contact"]
2;#Collins, Ben

_______________________________________________________________________________________
PS C:\> $list.Items[0]["Code"]

_______________________________________________________________________________________
PS C:\> $list.Items[0]["Code"] -eq $null
True

The "Code" field in the list doesn't actually have a null value, so I'm at a bit of a loss. Anyone know what might be going on?

+1  A: 

Turns out the feature containing this field type wasn't activated (the list had already been created, and I've been making changes to the feature).

Doh.

Ben Collins