JavaScript client library and taxonomy fields

With the JavaScript API it’s possible to retrieve information about all the fields in a list. In most cases this will work without a hitch, but the problem is when you are using TaxonomyFields in your list.

Normally you will receive an array of objects containing methods such as get_internalName(), get_typeAsString() etc. If you have taxonomy fields in your list, the entry in the array doesn’t contain the expected object, but rather just the raw data.

After a lot of investigating and troubleshooting, I discovered that the TaxonomyField type isn’t defined together with all the other field types. It’s defined in SP.Taxonomy.js; this is part of SharePoint Server, not SharePoint Foundation.

If you include a reference to SP.Taxonomy.js and make sure it has been loaded, everything works as expected.