Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SP.Social.SocialActor.tagGuid property (sp.userprofiles)

SharePoint 2013

Gets the actor's tag GUID. Applies to tags.

Last modified: August 09, 2013

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

var value = SP.Social.SocialActor.get_tagGuid()

Guid
The GUID of the tag.

The tagGuid property is valid only when actorType is a tag.

The following code example shows how to get the tag GUID from the Hashtags term set by using the tag name.

Before you run the code, add a reference to sp.taxonomy.js and change the placeholder tag name with the name of an existing tag. Keep the hash mark.

function getTagGuid() {
    var tagName = '#placeholderTagName';
    var clientContext = new SP.ClientContext.get_current();
    var label = SP.Taxonomy.LabelMatchInformation.newObject(clientContext);
    label.set_termLabel(tagName);
    label.set_trimUnavailable(false);
    var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(clientContext);
    var termStore = taxSession.getDefaultKeywordsTermStore();
    var termSet = termStore.get_hashTagsTermSet();
    terms = termSet.getTerms(label);
    clientContext.load(terms);
    clientContext.executeQueryAsync(
        function () {
            var tag = terms.get_item(0);
            if (tag !== null) {
                var tagGuid = tag.get_id().toString();
                if (!SP.ScriptUtility.isNullOrEmptyString(tagGuid)) {
                    alert(tagGuid);
                }
            }
        },
        function (sender, args) {
            alert(args.get_message());
        }
    );
}

Other resources

Show:
© 2015 Microsoft