Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
try using the $list.Fields["Region"] instead of $spItem –  David Lozzi Jun 22 '12 at 20:47
    
Did not help. $list=$web.Lists["Monthly Sales Report"] –  Angie Heimerlake Jun 23 '12 at 0:28
    
What do you get when you use $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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.