Export (0) Print
Expand All

SP.UserProfiles.PeopleManager.getTrendingTags Method (sp.userprofiles)

SharePoint 2013

Gets the most popular tags. getTrendingTags is a static method.

Last modified: September 26, 2013

Applies to: apps for SharePoint | Office 365 | SharePoint Foundation 2013 | SharePoint Server 2013

SP.UserProfiles.PeopleManager.getTrendingTags(context)

context

SP.ClientContext
The client context to use.

SP.UserProfiles.HashTagCollection
The 20 most popular hash tags over the past week, sorted so that the most popular tag appears first.

The following code example gets the trending tags in the current context.

var trendingTags;

// Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
SP.SOD.executeOrDelayUntilScriptLoaded(getTrendingTags, 'SP.UserProfiles.js');

function getTrendingTags() {

    // Get the current client context and call the getTrendingTags static method.
    var clientContext = new SP.ClientContext.get_current();
    trendingTags = new SP.UserProfiles.PeopleManager.getTrendingTags(clientContext);

    // Load the query and send the request.
    clientContext.load(trendingTags);
    clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);
}

// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {

    // Get trending tag information.
    alert('There are ' + trendingTags.get_count() + ' trending tags.');
    alert('The name of the first tag is ' + trendingTags.itemAt(0).get_name());
    alert('The use count of the first tag is ' + trendingTags.get_item(0).get_useCount());
}

// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
    alert('Error: ' + args.get_message());
}

Other resources

Show:
© 2014 Microsoft