I have been working on an integration that needs to read terms from SharePoint’s Managed Metadata service, for a particular field, and then populate that field with those values. All this has to be done via SharePoint’s web services – so the relevant ones here are the TaxonomyClientService, and Lists web service.
This has proved particularly bloody hard.
To start with, let’s look at what fields I needed to deal with. When you add a Taxonomy column to a list, it actually adds two columns.
The first is your ‘display’ column, and this can actually be one of two types – TaxonomyFieldType or TaxonomyFieldTypeMulti. As the name suggests, these are for single select and multi-select respectively.
The second column is a hidden field of the ‘Notes’ type. This stores your actual data, it appears, though quite why still mystifies me a bit (more on that later).
Anyway, there are two columns. As you can see from the screenshots above, the Taxonomy column contains an array of customisation properties.
So, how are these two fields related? Well, not using the ‘RelatedField’ attribute (too obvious), and when I did a bit of a search I kept finding blog posts saying that I would have one field with the name I gave it, and another field with the same number but ending with an additional “TaxHTField0” text. This was not the behaviour that I saw; it might have changed in a service pack.
On my system, the second (Notes) field seemed to have a GUID-like name. It looked mostly hexidecimal, but was often prefixed by a couple of non-hex characters. At first I thought that this might be the reference between the two fields.
However, the relationship is in fact one of the array of properties on the field:
The TextField property contains the ID of the Notes Field. Great, that’s nice and simple.
So, in summary, the relationship between the TaxonomyField and Notes field is held in the TextField property in the array of properties of the TaxonomyField. The value is the ID of the Notes field. You can get this information a variety of ways, but I used the GetListContentType method of the Lists web service.
In Part 2 we’ll look at getting and interpreting the TermSet for our field.