Nick Nick - 6 months ago 35
Vb.net Question

Sharepoint Updating MMS DocumentSet field

I have am writing some SharePoint 2013 integration to my companies product, to upload a document set with metadata and then upload some documents.
I have all this functionality working correctly, except for updating Document Set metadata fields that require MMS (Managed Metadata Service) fields.

dim docSetUrl as string = "http://someurl/"
Dim folder = Context.Web.GetFolderByServerRelativeUrl(docSetUrl)
Context.Load(folder)
Context.ExecuteQuery()
folder.Properties.Item("GeoObject") = "test" 'Normal string content (updates correctly)
folder.Properties.Item("Applicant") = "1353;#: Value A : REC-95342|9074b95b-9dcd-4c93-b548-32a5c7e7e083" 'Does not update correctly
folder.Update()
Context.ExecuteQuery()


Now as you can see from the code, I can update the
GeoObject
which just requires a string value, but for the Applicant object which is a MMS type, it just doesn't change (no errors).

If I log into SharePoint and manually use MMS to select an item, and then programatically check what it's value is : 353;#: Value A : REC-95342|9074b95b-9dcd-4c93-b548-32a5c7e7e083, if I clear the value manually and then try to push the found value back in, I still have no result.

How am I supposed to update a MMS field?

Thanks,

Answer

I was able to piece this together via lots of input from different sources. Such as https://unnieayilliath.com/2015/08/24/sharepoint-2013-updateclear-taxonomy-field-value-using-c-csom/

Dim value As TaxonomyFieldValue = New TaxonomyFieldValue()
                value.WssId = -1
                value.TermGuid = terms.First.Id.ToString
                value.Label = terms.First.Name

                Dim list As List = folder.ListItemAllFields.ParentList
                Dim field As Field = list.Fields.GetByInternalNameOrTitle("Property")

                Dim txField As TaxonomyField = Context.CastTo(Of TaxonomyField)(field)

                txField.SetFieldValueByValue(folder.ListItemAllFields, value)
                folder.ListItemAllFields.Update()
                Context.Load(folder.ListItemAllFields)
                Context.ExecuteQuery()
Comments