I am trying to update a metadata field when adding an item to document library. All the other columns are updating. The error is on this line and basically $taxfield is returning null.
$taxField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$spItem.Fields["Region"]
$termSet = $termStore.GetTermSet($taxField.TermSetId) >> error on this line.
I am running this code with Admin and have full permission to the list.
= = = Error = = = You cannot call a method on a null-valued expression. At C:\ps\AddFile.ps1:60 char:30 + $taxFieldState.SetFieldValue <<<< ($spItem, $termsST) + CategoryInfo : InvalidOperation: (SetFieldValue:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull
$taxField = $spItem.Fields["Region"]. Also try and paste some more of your code so we can understand what you are doing – Anders Rask♦ Jun 27 '12 at 11:23