I have a list "Orders" in SP, where I have some data. The list definition and instance were previously created in Visual Studio and then successfully deployed.
Today I've opened VS again and added new choice field "OrderType" to
schema.xml file. Also I've added this field to all views. Now, I can see it on list view pages, I can successfully set this field from codebehind when I adding new item:
SPListItem item = SPContext.Current.List.AddItem(); item["Title"] = "MyNewTitle"; item["OrderType"] = "Choice1"; item.Update();
But, when I'm trying to access this field from Powershell, I get error:
$web = Get-SPWeb http://myweb $list = $web.lists["Orders"] $items = $list.items $item = $items # Item with filled fields $item["OrderType"] # Returns nothing $item["OrderType"] = "Choice1" # Returns error $item.Update()
Unable to index into an object of type Microsoft.SharePoint.SPListItem. At line:1 char:7 + $item[ <<<< "OrderType"] = "Choice1" + CategoryInfo : InvalidOperation: (OrderType:String) , RuntimeException + FullyQualifiedErrorId : CannotIndex
In fact, I even can't find the field on web:
Exception calling "GetField" with "1" argument(s): "Column 'OrderType' does not exist. It may have been deleted by another user." At line:1 char:22 + $list.Fields.GetField <<<< ("OrderType") + CategoryInfo : NotSpecified: (:) , MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
I have full access permissions for the item. I can still see this field and its data on my list view pages.
Where am I wrong?