Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Loading _Sys_Nav_HoverText with REST

$
0
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?


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>