Showing Presence Information In SharePoint Web Parts

If you’ve visited a SharePoint site, you’ve probably noticed the Messenger-style icons in front of people’s names corresponding the IM status. When you hover the mouse pointer over that icon a lot of additional Messenger and Outlook functionality becomes available: you can send an email to that person, plan a meeting, … Isn’t the SharePoint – Office integration great? A nice example is the Members web part:

Patrick Tisseghem showed already in a demo during the Belgian Dev&IT-Pro Days, how you can use this functionality in your own web parts. but I couldn’t find any information on the net that showed how to do this. Well in fact is quite simple to accomplish this and you can easily test this in a SharePoint site. Just drag and drop a Content Editor web part on a SharePoint site, open the tool pane and click the Source Editor button. In the text entry window type following HTML:
My presence information:<br>
<span>
<img border="0" height="12" width="12" src="/_layouts/images/blank.gif" onload="IMNRC(
'themail@address.com')" id="IMID1" ShowOfflinePawn=1>&nbsp;Jan Tielens
</span>

The result (the menu showed above pops up when you hover over the image) is:

The magic happens in the IMNRC client-side Javascript function that’s called when the OnLoad event of the image is triggered. This function can be found in the /_layouts/1033/owsbrows.js file. Make sure your put span tags around image and the text, otherwise you’ll end up with some unexpected (but funny) behaviour. Also remember that you need to generate a unique id value for each presence information block. Finally, if you don’t want the offline image to show when the user isn’t online, you can omit the ShowOffLinePawn tag.

10 Comments

  • Ahhh, this gives me a HUGE clue as to issues I've been seeing with the out of box web parts! I have many questions as to why pawns aren't shown sometimes for offline users. Sounds like ShowOfflinePawn is dropped every so often.

  • Great post, Jan! Just to clarify - this still requires that the end user have Office 2003 installed to get the presence information, right?

  • Yep, as well as Messenger.



  • I saw this in the HTML and have been experimenting using it in my non-Sharepoint webpages too (i.e. intranet webpages that know about user identities), as long as I load the appropriate JS pages in the HTML header (owsbrows.js, ows.js, menu.js and ie55up.js) then I can use this from any webpage.



    I don't know what the MS situation is with doing this tho - the licensing position is not obvious, so I haven't actually put it into production yet, but the wow factor is impressive. The next stage, I know, is to replace those webpages with Sharepoint, but this is a quick win.



    Anyone know what the legal position is on calling this code from non-Sharepoint generated pages ??

  • I'm a beginner to all this, so maybe this is a stupid question, but when I do this, there is no presence icon until you mouseover? Is there a way to have the presence inciator there regardless?

  • Great!
    I have been looking for ANY information regarding this for a while.
    Now, my next question is, what is the best way for utilizing this in my own custom webpart?

    I am using the CreateChildControls() method to output the content in my webpart. Can I use this to output the presence information of the users my webpart handles? If so, how? Or do I need to do some combination with the Render() method?

    Any clarifiaction will be greatly appreciated :-)

  • To clarify my last question:
    I need to do this programatically (in code-behind) as my webparts that will use this handles everything i code.
    Currently I am experimenting with using TemplateColumn and trying to put the html for the presence of a user dynamically into each row of a datagrid. My I seem to come up short of a good solution.
    Please help!

  • this is an excellent Help, i coud implement that, but i dont know how i can put a SPAN roud a cell in a dataGrid, sorry, excuseme, could you said how can i do that

    thanks

  • Why the members webpart shows several users that are online, and do have Office 2003, as offline? I have a wss site with a members webpart and several users that are showing online on Communicator, appears as offline in the webpart.

  • Lucy! Please call me,Lucy! Please call me

Comments have been disabled for this content.