Displaying Tags & Notes on Items in SharePoint 2010

This post is a continuation of an article written by Glyn over on his blog. You can read the full article here: Showing which list items have tags or notes in SharePoint 2010.

What I’ll be covering in this post, is extending his article to solve the issues he mentions in his Next Steps and Limitations bit:

I’m fairly happy with the result that this script and technique gives, although there are some nagging annoyances. Whilst investigating this I tried to repeat the same behaviour as the Tags And Notes icon found in the ribbon, i.e. it would be nice to be able to click on the icons and view/ add tags and notes for the individual items. Unfortunately I found that by adding in the functions to open up the dialog with multiple instances on a page it would always refer to the first item clicked.

So to begin, let’s review his process:

  1. Let’s assume you have a document library called Shared Documents.
  2. Within the Shared Documents document library, create a new column named Tags And Notes. In this case, both Glyn and myself used Single Line of Text.
  3. On the home page of your team site, you’ll want to add the Shared Documents web part to the page, and within the web part properties, modify the view so that the Tags And Notes column is visible.

  4. Upload the script that Glyn put together into a suitable location. In my case, I uploaded it into the Site Assets library as he recommends. You’ll want to name the file jquerysocialdata.js. I’ve made modifications to this file, that I’ll discuss shortly, so you can grab an updated version of this file from here.
  5. Reference the script in a Content Editor Web Part (CEWP) added to the same page that the Shared Documents web part has been added to.
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="/SiteAssets/jquerysocialdata.js"></script>

Now let’s talk about the changes I made to get this to work. I want to mention that I ran into the exact same issue as Glyn initially. The logic I had added to popup the Tags and Notes in a modal would only ever display the data for the first item I happened to click on. If I refreshed the page, and clicked on a different item, that item would load correctly. Any subsequent items I clicked on, would always load the data from the first item clicked. So some sort of caching going on.

Initially, the logic I was trying to emulate was leveraging the TagDialogOpener.Open call, which is exactly the same call that’s used by the Tags & Notes icon in the Ribbon.

SafeRunFunction(function() { TagDialogOpener.Open(strUrl, title, '0'); }, 'SocialData.js', 'TagDialogOpener');

However, nothing I did would result in it loading the correct data after the second click. I spent a lot of time breaking down and looking into how this call was made, even going so far as reviewing the SocialData.js file that it’s ultimately pulling from, and while my understand of it all was a lot better, it didn’t result in a solution.

So I went about it a different way. I decided to leverage the SPModal class and make the call myself. Below are the changes I had to make to the jquerysocialdata.js file to make this work. Please note you don’t have to make any of these changes, I’ve done it for you already.

  1. First thing I did was in the OutputTagsAndNotesImage method, I added an onclick event to the ms-mini-socialNotif a tag. This call required two parameters: strUrl and title. Since neither of these two were being passed into this function, I modified the FindTagsAndNotes function so that they were sent through.
  2. I then added a new function SendTag that basically wired up the link to open a modal dialog when the image was clicked.
    function SendTag(strUrl, title) {
    	// remove first '/'
    	title = title.substring(1);
    	// replace '/' with ' - '
    	title = title.replace('/', ' - ');
    	var f={url:location.protocol + '//' + location.hostname + "/_layouts/socialdataframe.aspx?Url="+strUrl+"&mode=0",args:null,title:title,width:600,height:470};
  3. One thing to note, is that the mode parameter determines whether the modal opens the Tags tab by default or the Note Board tab by default. By tweaking this parameter, so 1 for Note Board and 0 for Tags, you can modify it’s default behaviour.

    How cool is that? Give it a try and let me know if you run into any issues!

16 Responses to “Displaying Tags & Notes on Items in SharePoint 2010”

  1. Jakob Nøtseth December 12, 2012 at 1:50 am #

    Hi, add title to the url-querystring to avoid caching issues

    var f={url:location.protocol + ‘//’ + location.hostname + “/_layouts/socialdataframe.aspx?Url=”+strUrl+”&mode=” + mode + “&Title=” + title,args:null,title:title,width:600,height:470};

  2. shereen December 24, 2012 at 12:40 pm #

    Interesting Jakob, were you having caching issues with the code above that were resolved by adding Title?

  3. Duncan April 2, 2013 at 4:42 am #

    Hi Shereen, I can’t get this to work – I’m trying to add it to an announcement for internal communications – our comms department would like to know what staff think of the posts they make? Any ideas?

  4. shereen April 7, 2013 at 6:08 pm #

    Hi Duncan,

    What have you tried? Or do you have any errors you can give me that might help us troubleshoot together?

  5. Jakob nøtseth June 7, 2013 at 2:06 am #

    Hi shereen,

    Yes i had some caching issues. i think this was because I made a custom news-webpart that called the script. When I didn’t have the title in the url, it would reload the first dialog and commenting/liking was saved to the first old news clicked instead of the current.

  6. René September 12, 2013 at 10:38 pm #

    Hi Shereen, wonderful implementation and very useful to pull SharePoint Social features to a more prominent place!

    I managed to rebuild your solution with a document library, but have failed so far for a custom list. When I click on the Tags/Notes-Icon the modal dialogue opens and there’s an error message saying “list not found”. I guess this is because there’s an additional “/lists/” in the url to a custom list that is missing for document libraries?

    Do you have a clue on how to adapt the script for custom lists?

  7. Naama Efrati-Khirman December 16, 2013 at 6:45 am #

    I saved the java script, and used my local copy of jQuery (which is working with many other stuff on my site). Then I added the CEWP to my page, and got the Tags And Notes column with the icon. I clicked the icon and got the following error (after validating i do have tags there):
    List does not exist.
    The page you selected contains a list that does not exist. It may have been deleted by another user.
    Correlation ID: d4eac6c5-3658-4367-b70c-44f57567b94b

    Any clue what can this be?

  8. Naama Efrati-Khirman December 16, 2013 at 1:31 pm #

    Not working for me. i’m getting an error that the list does not exist. Any clue what can that be?

  9. Michelle March 11, 2014 at 8:33 pm #

    I love your code, it works like a charm. Could you help with extending your solution even further? I have sucessfully added the new Tags and Notes column and would like to display that column in a content query. I have a custom template in item.xsl that I created and when I add , it does not return anything. I did add the javscript file to page where the CQWP is located. Do you have any ideas? Appreciate your help. Thanks.

  10. Shereen Qumsieh April 28, 2014 at 5:38 pm #

    Hmm very interesting Michelle. I haven’t tried this in a content query. Did you ever resolve this? Does the JS throw any errors?

  11. Ryan July 29, 2015 at 2:48 pm #

    Have you updated this for SP2013?

  12. Shereen Qumsieh August 4, 2015 at 4:06 pm #

    No I haven’t.

  13. Polina September 30, 2015 at 9:30 am #

    Dear Shereen,

    Thank you for your the most useful post! The scrip you wrote works perfectly with libraries, but not with Announcements list. I would appreciate your help to find the problem.

    When I click on the “Tags And Notes” icon next to the announcement it redirects me to the common Note Board, which is the same for all announcements. Therefore there is no way I can distinguish which post corresponds to which announcement. The name of the window is “ndefined”, so I guess the link to the ribbon is wrong? When I select the announcement and go to “Tags&Notes” on the ribbon, I see another window with individual notes, which are not displayed in the common Note Board I was describing previously.

    Could you kindly help?
    Many thanks in advance,

  14. Polina September 30, 2015 at 9:54 am #

    Dear Shereen,

    I found out that List item is identified by Item ID (number), not Title, which is the case for the library. But there is no such column as Record ID, for example… I’m stuck here and my coding abilities are very limited, so your help is very much appreciated.

    Thank you in advance,

  15. Polina September 30, 2015 at 12:02 pm #

    Dear Shereen,

    Thank you very much for your script! It works very well with libraries, but I can’t make it work with a list.

    As I understood, list item is defined by Item ID, not Title, which is the case for libraries. Therefore in order to build a link to Tags and Notes I have to use Item ID (function FindTagsAndNotes()). There is no such column though, Item ID is defined somewhere inside of SP. Could you please help me with this? How should I modify the link builder?

    Thank you in advance,


  1. Display tags&notes for a list item | Asking - September 30, 2015

    […] found a very good solution here. It doesn’t work for lists though, only for libraries. As I understood, the problem lies in […]

Leave a Reply