Failed to update the metadata field managed by SharePoint 2010 by calling the List.UpdateListItems web service.

I am trying to update a SharePoint managed metadata field (MMD) using the List.UpdateListItems web service, but it does not work.

Here is my SOAP request

<?xml version="1.0" ?> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>My Test List</listName> <updates> <Batch ListVersion="0" PreCalc="TRUE" OnError="Continue"> <Method Cmd="Update" ID="1"> <Field Name="ID">3</Field> <Field Name="Document_x0020_Title">foo</Field> <Field Name="Fiscal_x0020_Year1">13;#FY 2006|7e8205da-57a1-45a3-8147-469b795ad6e8</Field> </Method> </Batch> </updates> </UpdateListItems> </S:Body></S:Envelope> 

This request will successfully update the "Document Name" (text field), but the MMD "Fiscal Year" field has not changed and there is no error returned by the web service.

Please note that the MMD value is in the format "WssId; #TermValue | TermGuid", and this term has already been created for the site.

Please, help.

+8
sharepoint 2010
source share
2 answers

Figured it out.

I have to use a different field name. Bright for the field is Fiscal Year, but the name of the field that worked is actually "d3c0ddc947ab4b8c90b6a0fe2d4caf09" instead of "Fiscal_x0020_Year1". So my SOAP request will look like

  <Method Cmd="Update" ID="1"> <Field Name="ID">3</Field> <Field Name="Document_x0020_Title">foo</Field> <Field Name="d3c0ddc947ab4b8c90b6a0fe2d4caf09">13;#FY 2006|7e8205da-57a1-45a3-8147-469b795ad6e8</Field> </Method> 

To get this field name, I use the List.GetListContentType web service method to return the field information and search for the Note field type. Here is an example of what SharePoint returned

 <Field Type="Note" DisplayName="Fiscal Year_0" StaticName="d3c0ddc947ab4b8c90b6a0fe2d4caf09" Name="d3c0ddc947ab4b8c90b6a0fe2d4caf09" ID="{1afa458b-d50a-4139-ad8d-f1172774de34}" ShowInViewForms="FALSE" Required="FALSE" CanToggleHidden="TRUE" SourceID="{77871b4e-f3ba-42dc-8940-ab33fb431099}" Hidden="TRUE" Version="1" Customization="" ColName="ntext8" RowOrdinal="0"/> 

I also find it useful to use the List.GetListContentTypes method to use the content type identifier in a call to the List.GetListContentType method.

---- Update - I found that you do not need to use the format "WssId; #TermValue | TermGuid". You can simply use "TermValue | TermGuid". Thus, in the example above, the value would be "FY 2006 | 7e8205da-57a1-45a3-8147-469b795ad6e8".

This is very useful because you can reuse the same value on different sites, unlike the previous value, where you can use it on only one site. For plural value you only need to delimit it with ;; instead of "; #". For example, "FY 2006 | 7e8205da-57a1-45a3-8147-469b795ad6e8; FY 2007 | 823205da-57a1-45a3-8147-469b795ade13".

+9
source share

Thanks for mentioning a bit about StaticName. This put an end to my misery.

It would seem that for simple fields that are not MMS-related, for example Title, the syntax of lazy updating is allowed. For example, based on it, the next update is processed without errors.

 <Field Name="Title">Some Title</Field> 

However, the rules do not match for MMS-related rules. Following the above approach, I went to my MMS fields. This type of field can be updated with arbitrary values ​​if you identify it by a friendly name and enter an integer, for example:

 <Field Name="Activity">20</Field> 

"20" just translates into some term.
I tried many numbers and they all came back as the same term.

Alternatively, if I approach the documented way of updating the value, while identifying the field with "Activity", the service returns error 0x80020005.

 <Field Name="Activity">HTA|fe951639-7c90-41ee-9888-6ae0e6523120</Field> 

So don’t do it. Only when the moons are fully aligned do I find success. A static name is key .

 <Field Name="j06a8d8240f84aec987f6a28effa3ae1">HTA|fe951639-7c90-41ee-9888-6ae0e6523120</Field> 

Another way to search for StaticName is to search for field type = "Note" for each MMS field in response to a GetList request. This operation takes less than 1 input than GetListContentType. You only need the list name, not the contentTypeID.

Rock on.

0
source share

All Articles