Setting taxonomy field values

Dec 6, 2011 at 5:31 PM

Hi folks,

First of all, since is my first post here, I'd like to commend you Marc, and of course the other contributors, for your work on this.  It's a very cool system, and I only became aware of it recently.

I'm creating my Item Edit form, which updates its list items by catching onBlur() in the input controls.  This way we can create a really nice and responsive UI, and in general this has worked well.   The problem is that it seems there's no way to update Taxonomy fields.

I'm able to collect the information by setting up

value = $("#<%=tctl.ClientID%>").find("input:first-child").attr('value');

For this, I might get the (mutli) value:

Contracting|960a3625-d187-4f17-a39d-1d549465cacb;Selecting|b3ca7068-830b-4380-83f0-87250c4ad6f5

However, using the "generic" function which I set up to update list items, does not seem to work.

 

function updateValue(field, value) {
    $().SPServices({
       operation: "UpdateListItems",
       async: false,
       batchCmd: "Update",
       listName: "<%=listName%>",
       ID: itemID,
       valuepairs: [[field, value]],
       completefunc: svcRequestComplete
     });
}

Has anyone had experience with this? Any solutions or suggestions?

Thanks.

Dec 23, 2011 at 10:53 AM
Edited Dec 23, 2011 at 10:53 AM

Just for follow-up: I could not find a way to set taxonomy field values using spservices, so I created my own web service.   I'm hoping to document this in a blog at some point.  I'll post back here once I do.

Coordinator
Dec 30, 2011 at 2:09 PM

mmendelson:

Sorry I never got back to you on this, but I hadn't gottan a chance to test it out. I'd definitely be interested in any details you can provide on what you found. I get questions about setting metadata fields in lists, but I don't know the answers yet.

M.

Jan 30, 2012 at 3:09 PM

Hi

Any update on this?  I need to be able to update metadata column data within my document libraries.  I'm assuming one would use the new SPServices Taxonomy webservice to add new terms to the metadata (mine are site collection specific) but I can't yet find a way to update the column with new or existing terms.  I can find the SharedService ID and the TermSet ID etc by accessing the hidden taxonomy list at [site url]/Lists/TaxonomyHiddenList/AllItems.aspx.

Des

Oct 12, 2012 at 1:32 PM

Hi,

very old discussion but answering mostley so I can find the answer myself next time I need it :-)

It looks like you can't update the specific Managed Metadata field directly, but the field has a corresponding hidden text field that shoud be updated instead. Below is my Managed Metadata field

<Field Type="TaxonomyFieldType" DisplayName="Agreement Type" List="{eb6ead69-5667-49ba-bae7-0f58cfd6aeb6}"
WebId="571eaa16-011c-46c8-9f50-ff9e62756d9b" ShowField="Term1033" Required="FALSE"
EnforceUniqueValues="FALSE" Group="Custom Columns" ID="{ba1d5078-44cc-4703-9a12-7d80166ccdbe}"
SourceID="{571eaa16-011c-46c8-9f50-ff9e62756d9b}" StaticName="Agreement_x0020_Type"
Name="Agreement_x0020_Type" Version="5" ColName="int3" RowOrdinal="0" Indexed="TRUE">

Based on this field ID, {ba1d5078-44cc-4703-9a12-7d80166ccdbe} the name of the hidden field is generated: ba1d507844cc47039a127d80166ccdbe

<Field Type="Note" DisplayName="Agreement Type_0" StaticName="ba1d507844cc47039a127d80166ccdbe"
Name="ba1d507844cc47039a127d80166ccdbe" ID="{4f95bfc5-db67-4b34-bbf9-cd1052f1dd82}"
ShowInViewForms="FALSE" Required="FALSE" Hidden="TRUE" CanToggleHidden="TRUE"
SourceID="{571eaa16-011c-46c8-9f50-ff9e62756d9b}" Customization="" ColName="ntext2"
RowOrdinal="0" />

Updating this field will lead to an update in the Manage Metadata field. The IdForTerm used is found in the [site url]/Lists/TaxonomyHiddenList/AllItems.aspx list described above. Example below

$().SPServices({
	operation: "UpdateListItems",
	batchCmd: "Update",
	listName: "Record Library",
	ID: 13,
	valuepairs: [["ba1d507844cc47039a127d80166ccdbe", 'Agreement type 1|dc3eb298-4f46-41ca-a662-e3a273b04cdf']],
	completefunc: function (xData, Status) {
		$("#tex").val(xData.responseText);
	}
});

/Fredrik