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

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

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

var value = SP.Social.SocialActorInfo.get_tagGuid()
SP.Social.SocialActorInfo.set_tagGuid(value)

Return value

Guid
The GUID of the tag.

Remarks

This property is valid only when id is null or empty and actorType is a hash tag (value = 3).

Code example: Get a tag's GUID based on the tag's name by using the JavaScript object model

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());
        }
    );
}

See also

Other resources

SocialActorInfo