0

I'm building a SharePoint 2016 app with a custom site map menu that utilizes the site's managed navigation. How do I retrieve the "Navigation Hover Text" value?

I'm using the REST API to retrieve the site map in XML form, works great.

http://<site>/_api/navigation/menustate?mapProviderName='GlobalNavigationTaxonomyProvider'

I tried adding it to the customProperties parameter, but it returns an HTTP 500 error:

http://<site>/_api/navigation/menustate?mapProviderName='GlobalNavigationTaxonomyProvider'&customProperties='_Sys_Nav_HoverText'

I thought I had a workaround by using the JSOM functions in sp.taxonomy.js and SP.Taxonomy JavaScripts:

var context = SP.ClientContext.get_current();
var taxonomySession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
var term = taxonomySession.getTerm(data.guid);
context.load(term, ['LocalCustomProperties']);
context.executeQueryAsync(Function.createDelegate(this, function (sender, args) {
   data.hoverText(term.get_localCustomProperties()['_Sys_Nav_HoverText']);
}), Function.createDelegate(this, function (sender, args) {
   console.log('The following error has occured while loading hover text: ' + args.get_message());
}));

During QA we found this errored out for users in the Site Visitors group. It works if either the "Available For Tagging" option is checked in the Intended Use tab of the Site Navigation term set, or, the user is a member of the Contributors/Managers in the term set's parent. Neither of those options is desirable.

I proposed a workaround to add a custom property to each term named _nav_hovertext which could then be retrieved with the REST API, above, but the client said that was cumbersome and surely Microsoft wouldn't have omitted retrieving the existing field from the API, right?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.