Search code examples
sharepoint-2013taxonomy

TaxonomyField.Open is always false


When checking the TaxonomyField for the .Open flag, the field is always set to false.

This is however only for our Codebehind code, and not inside SharePoint itself, in SharePoint the Open flag is shown in the Manage Meta Data Store application.

In general, we cast the SPField to TaxonomyField, and check the Open flag, when it's open, we show an extra input box to add more items to the taxonomystore.


Solution

  • I will post the solution to my question here, as no one did so far :)

    So, if you want to check if the TaxonomyField.Open is set, it depends on 2 configurations:

    • Is the Termset open for new submissions
    • Is the field inside your list set to "Allow input values"
      • Site Contents -> List settings -> Field -> Allow input values

    Then you can iterate the fields and take action on the open flag, eg:

    foreach (SPField field in item.Fields) {
        if (field is TaxonomyField) {
            var taxField = field as TaxonomyField;
            if (taxField.Open) {
                // field is open for this termset in this list (for this user)
            }
        }
    }