What does TaxonomyItem.NormalizeName() do?

So, the client side application I’ve been working on has to sync a LOT of terms to the term store, and I’ve mentioned how I had problems with Managed Metadata labels and the ampersand – and how I fixed them using TaxonomyItem.NormalizeName().

Well, that was fine, but my application was slow – so I started looking at what I could do to eliminate client side object model calls (CSOM). My suspicion was that, as the function was static, it wasn’t doing anything that I couldn’t do in my application, and save a round trip to the server.

So, I opened up reflected and decompiled Microsoft.SharePoint.Taxonomy.dll. Inside I found the code for the following:

Regex _trimSpacesRegex = new Regex(@"s+", RegexOptions.Compiled | RegexOptions.IgnoreCase);
//Normalize name as Taxonomy Service does
string name = _trimSpacesRegex.Replace(termName, " ").Replace('&', 'uff06').Replace('"', 'uff02').Trim();

That’s much, much faster than a round trip to the server, and I learnt that speechmarks are also converted from ASCII to Unicode too.

Advertisement
What does TaxonomyItem.NormalizeName() do?

Managed Metadata Labels and the Ampersand character

I am writing an application to import/generate a number of terms in a term set. I started to get some errors about my code trying to add terms that already exist – but it does check for the existence of terms with a given name.My Code and existence check

You can see that the string comparison for the name of the existing term and the term I want to get/create returns false, and that the terms seem to be different lengths. Well, I tried looking for blank spaces, non-printing characters, carriage returns, etc., and found nothing. Then I looked really closely at the ampersand characters shown in the debugger:

Strings in the Debugger

Yup, they’re different characters. You can see a slightly different shape to each of them – one is wider. Continue reading “Managed Metadata Labels and the Ampersand character”

Managed Metadata Labels and the Ampersand character

What happens with a large TaxonomyHiddenList?

SharePoint’s Taxonomy (or “Managed Metadata”) fields are a bit strange in how they work. In a lot of ways they’re actually like a lookup field, and part of this lookup field is that site collections that use them have a hidden list – called TaxonomyHiddenList – in the root of the site collection. You can find it at /lists/TaxonomyHiddenList/.

Hidden

Each term that is used in a Taxonomy field has it’s label (actually, labels) and other details kind of ‘cached’ in this list, and there is a timer job that will push changes to the terms out into these lists – and therefore to items that refer to the entries in the list. Continue reading “What happens with a large TaxonomyHiddenList?”

What happens with a large TaxonomyHiddenList?

Column Indexing Oddities in SharePoint

I’ve come across a few issues lately with list column indices (indexes?) in SharePoint that have caused some trouble recently.

  • Multi-valued columns cannot be indexed. It doesn’t matter what type they are, they can’t be indexed. This isn’t actually so surprising when you think about it – where in the index would they be – though it might be nice if they simply appeared in it twice. To be honest, I’d known this for some time, but it did catch me out recently.
  • Lookup Columns can’t be used in ListViews set up through the UI. It seems that the SharePoint UI sets the list view up to filter using the ‘text’ of the column, which isn’t indexed – rather than using the LookupId, which is. A List View in a list definition, or set up through code, can therefore be fine…
  • The Approval Status column added by Content Approval can’t be indexed.
  • Single-valued Managed Metadata (Taxonomy) columns can be indexed – but not sorted. ORDER BY clauses won’t work (more on how to solve that in a later post). I think this is due to multi-lingual support – but it is a pain.

Yes, some of these issues are particularly acute given some of Office 365’s search limitations, and awkwardness with Content Approval.

Column Indexing Oddities in SharePoint

Using JSOM to query SharePoint 2013 lists with Taxonomy Fields

So, I’d an interesting problem. I have a SharePoint 2013 list that uses a Managed Metadata (or ‘Taxonomy’) field. I need to, through the JavaScript Client Object Model, get all items that have a particular value or a child of that value on the taxonomy tree. As an example, here’s my taxonomy:termSet Sounds like it should be simple to query this, right? Well, not so much. Continue reading “Using JSOM to query SharePoint 2013 lists with Taxonomy Fields”

Using JSOM to query SharePoint 2013 lists with Taxonomy Fields

Content Type Hubs and the Blank Site Template – Fixing them

So, I’ve somehow managed to get through most of the SP2010 cycle without having to use the Enterprise Content Type hub – until last week. This was my opportunity to stumble across one of the gotchas of the ECT hub – it doesn’t work with blank sites. We had a number of site collections based on the Blank site template, and content types would not replicated to it. Other site collections based on other templates – such as Team sites – worked fine.

Interesting. And this tickled a neuron. Continue reading “Content Type Hubs and the Blank Site Template – Fixing them”

Content Type Hubs and the Blank Site Template – Fixing them

Working with the TaxonomyClientService: Part 4 – Populating Values with the Lists web service

So far I’ve discussed how to get information about getting the types of taxonomy field, working with those fields, and how to get term sets. What about setting values on list items?

It isn’t immediately obvious how to do that. For a start, we wouldn’t actually be using the TaxonomyClientService. To set values on items, you use the Lists web service, using the UpdateListItems() method. This accepts XML describing the field and values.

But what fields do we submit, and what values? After all, as mentioned in part 1, there are two fields – one for the displayed value, and a hidden ‘notes’ field that contains the actual data!

There was no documentation about how to set these values, and limited and contradictory information in blog posts, so I investigated…

Continue reading “Working with the TaxonomyClientService: Part 4 – Populating Values with the Lists web service”

Working with the TaxonomyClientService: Part 4 – Populating Values with the Lists web service

Working with the TaxonomyClientService: Part 3 – Caching

In Part 2 of this series I described how to retrieve a TermSet, and interpret the results. I suggested using code:

string clientTimestamps = string.Format("<timeStamp>{0}</timeStamp>", lastClientCacheTime );
string clientVersion = "<version>1</version>";
string termStoreIds = string.Format("<termStoreId>{0}</termStoreId>", termStoreId.ToString("D"));
string termSetIds = string.Format("<termSetId>{0}</termSetId>", termSetId.ToString("D"));
string serverTermSetTimestampXml;
string result = _wssTax.GetTermSets(termStoreIds, termSetIds, 1033, clientTimestamps, clientVersion, out serverTermSetTimestampXml);

Fine, but what are these properties we’re passing into GetTermSets()? Continue reading “Working with the TaxonomyClientService: Part 3 – Caching”

Working with the TaxonomyClientService: Part 3 – Caching

Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)

In Part 1 I looked at the structure of our Taxonomy field – which is in fact two fields. We also saw how the TaxonomyField definition has an array of properties related to it too. As a reminder, here’s a screenshot of the XML for it:

These properties are quite important, as they tell us what we need to know to get the correct TermSet for our field. Continue reading “Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)”

Working with the TaxonomyClientService: Part 2 – Get the TermSet (and understand it!)