1

So I have a term store created and populated with terms, and I'm writing a script to retroactively tag items. During preliminary poking around, I found I can successfully tag an item with simply $item.properties["RelevantTerm"] = $value; $item.update(); $list.update(); where $item is an SPListItem and $value is a string I copied from a different item that already had a tag set haha.

How can I untag an item? $item.properties["RelevantTerm"] = $null; $item.update(); $list.update(); doesn't work; $item.properties["RelevantTerm"] still prints the value I set it to earlier.

  • Thanks, @BlueBird! For this script, the term store will have been created. I want to retroactively tag documents based on their names. So I think I would simply want a dict of terms to confirm a term actually exists before trying to assign it and to get the GUID. – Matt H Oct 7 '13 at 15:21
1

Working with taxonomy fields can be tricky...

In order to clear a value from a field:

$taxField = $item.Fields["metadataField"] -as [Microsoft.SharePoint.Taxonomy.TaxonomyField]
$taxFieldValue = $taxField.GetFieldValue("");
$taxField.SetFieldValue($fileItem,$taxFieldValue)
$fileItem.Update()

In order to set a taxonomy field you essentially need to know the guid of the taxonomy term. There are several ways you can get this and the best method depends on the context of your script. If you want to post more details i'd be happy to append to my answer.

Reference: http://matthewyarlett.blogspot.com/2013/03/clear-delete-value-of-taxonomy-field.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.