sharepoint 2013 how to update managed metadata field (TaxonomyFieldType) using soap API
-
08-02-2021 - |
Question
I am trying to update managed metadata field (TaxonomyFieldType) using SOAP API following is my SOAP XML
<Batch OnError = "Continue">
<Method ID = "1" Cmd = "Update">
<Field
Name = "ID"
xsi:type = "xsd:string"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">12</Field>
<Field
Name = "TaskOutcome"
xsi:type = "xsd:string"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">Approved</Field>
<Field
Name = "Title"
xsi:type = "xsd:string"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">sample</Field>
<Field
Name = "FileRef"
xsi:type = "xsd:string"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">sample.txt</Field>
<Field
Name = "MM"
DisplayName = "MM_0"
Type = "TaxonomyFieldTypeMulti"
xsi:type = "xsd:string"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">-1;#test2|168baffc-6f72-46cd-8750-98d53ed1acca</Field>
</Method>
</Batch>
There is no error from the server and managed metadata filed not getting updated.
Could you please help me that i am doing somethink wrong here...
No correct solution
OTHER TIPS
When you add Managed metadata field in SharePoint with Note fieldType It will add a hidden field with field type Note and Non-hidden field with field type as TaxonomyFieldTypeMulti or TaxonomyFieldType
<Field
Name = "MM"
DisplayName = "MM_0"
Type = "TaxonomyFieldTypeMulti"
xsi:type = "xsd:string"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">-1;#test2|168baffc-6f72-46cd-8750-98d53ed1acca</Field>
Instead of updating the above field you need to update its hidden Note field type with DisplayName = "MM_0" and Name = "Some Id"
<Field
Name = "of525fec62a44747aa623e3c49dac9e8"
DisplayName = "MM_0"
Type = "Note"
xsi:type = "xsd:string"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">test2|168baffc-6f72-46cd-8750-98d53ed1acca</Field>
In SOAP your request should be like this below
<Method Cmd="Update" ID="1">
<Field Name="ID">12</Field>
<Field Name="Title">Sample</Field>
<Field Name="of525fec62a44747aa623e3c49dac9e8">test2|168baffc-6f72-46cd-8750-98d53ed1acca</Field>
</Method>
If you used the schema generate schema with the hidden field type as Note You will get schema with "Name="of525fec62a44747aa623e3c49dac9e8" you can easily update that value.
Sharpoint return as Note fieldType as
<Field Type="Note" DisplayName="MM_0" StaticName="of525fec62a44747aa623e3c49dac9e8"
Name="of525fec62a44747aa623e3c49dac9e8"
ID="{6DDB9ADF-BC5E-4D07-BE70-F450A24C7520}" ShowInViewForms="FALSE" Required="FALSE"
CanToggleHidden="TRUE" Hidden="TRUE"/>
I hope the above explanation will solve your issue !!!