I am calling the 'SocialDataService.GetTags' web service method to try and obtain the Tags for a specific SharePoint item in a list or for a SharePoint document in a Document library.

For the Document I use the 'FileRef' property value to calculate the URL but the same does not work for a SharePoint item.

What is the best way to construct a URL for an item or document which can be used in the 'GetTags' method?

1 Answer 1


Apparently SPListItem.Url for Lists could not be used in Social Tags since the methods:

SocialTagManager.GetTags Method (Uri)


SocialTagManager.AddTag Method (Uri, Term)

expect a valid URI to be provided.

But in case of Lists the url of list item form could be specified as demonstrated below:

http://intranet.contoso.com/Lists/Nokia Offices/DispForm.aspx?id=1

The following method could be used for determining SPListItem Url:

    /// <summary>
    /// Generic method for retrieving SPListItem Url
    /// </summary>
    /// <param name="item"></param>
    /// <returns></returns>
    public static string GetListItemUrl(this SPListItem item)
        string itemUrl = null;
        switch (item.ParentList.BaseType)
            case SPBaseType.DocumentLibrary:
                itemUrl = SPUrlUtility.CombineUrl(item.Web.Url, item.Url);
            case SPBaseType.DiscussionBoard:
            case SPBaseType.Issue:
            case SPBaseType.Survey:
            case SPBaseType.GenericList:
                //Display Form By default
                itemUrl = item.Web.Url + "/" + item.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + "?id=" + item.ID;
        return itemUrl;
  • Thanks for the reply. Btw do you have any idea how about this question. stackoverflow.com/questions/18506686/… Nov 19, 2013 at 9:38
  • What is the value that should be used to index the 'Forms' collection? Is that something I get from the API or can I use a fixed value there? Nov 22, 2013 at 14:59
  • PAGETYPE.PAGE_DISPLAYFORM (value 4) specifies the type of a display form, for all available types please follow MSDN: msdn.microsoft.com/en-us/library/… Nov 27, 2013 at 10:25
  • Since I am using the Client Object Model, I used the 'List.Forms.GetByPageType(PageType.DisplayForm)' method. Nov 27, 2013 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.