Udostępnij za pośrednictwem


How to add presence/pawn to SharePoint contacts list

I have often been asked to add the presence icon and functionality to custom developed web parts or SharePoint pages. As you are probably aware this is a very simple thing to do, the secrect lies in calling the IMNRC jscript function passing in an email address in the rendered html. e.g. IMNRC(<'administrator@somewhere.com'>). You don't really need to know, or probably don't care how this actually works behind the scenes, so in summary; the IMNRC function calls an ActiveX control (called "name.dll") on the users machine which does the work, this control is installed with Office 2003. So developing web parts of custom SharePoint web pages with presence support added is pretty easy.

However, recently I had the requirement to show presence info on the email address field in the out of the box contacts list for WSS sites. I am not 100% sure why this feature was not added by the product team, but I guess it's because your contact list may have email addresses from users outside of your organisation and hence the presence information wouldn't make much sense. Anyway, I set myself the challenge of adding this. In theory it is not that difficult, you need to modify the CAML in the schema.xml for the contacts list to change the HTML that is rendered for the allitems view, i.e. inject the IMNRC function call for the email address field. In theory easy, in practice a little bit of a pain. I have therefore attached the sample CAML that I used in schema.xml for the contacts list. This is the viewbody section in the all contacts view i.e. <View BaseViewID="1">. Remember, this is sample code that you must test fully before deploying. Good luck!

<!-- for each field, if the field is called e-mail then spit out the imnrc function with the raw email address-->

<ViewBody>
<HTML><![CDATA[<TR>]]></HTML>
<Fields>
<HTML><![CDATA[<TD Class="]]></HTML>
<FieldSwitch>
<Expr>
<Property Select="ClassInfo" />
</Expr>
<Case Value="Menu">
<HTML>
<![CDATA[ms-vb-title" height="100%]]></HTML></Case>
<Case Value="Icon">ms-vb-icon</Case>
<Default>
<FieldSwitch>
<Expr><Property Select="Type" /><PresenceEnabled /> </Expr>
<Case Value="UserTRUE">ms-vb-user</Case>
<Default>
<FieldSwitch>
<Expr>
<Property Select="Name" />
</Expr>
<Case Value="Email">ms-vb-user</Case>
<Default>ms-vb2</Default>
</FieldSwitch>
</Default>
</FieldSwitch>
</Default>
</FieldSwitch>
<HTML><![CDATA[">]]></HTML>
<FieldSwitch> <Expr><Property Select="Name"/></Expr>
<Case Value="Email">
<HTML><![CDATA[<table cellpadding="0" cellspacing="0" ID="Tbl_]]></HTML>
<ID/>
<HTML><![CDATA["><tr><td style="padding-right: 3px;"><img border="0" valign="middle" height="12" width="12" src="/_layouts/images/blank.gif" onload="IMNRC(']]></HTML>
<Column />
<HTML><![CDATA[')" id="mnid]]></HTML>
<ID/>
<HTML><![CDATA["></td><td style="padding-top: 1px;" class="ms-vb"> ]]></HTML>
<Field/>
<HTML><![CDATA[</td></tr></table>]]></HTML>
</Case>
<Default><Field/></Default>
</FieldSwitch>
<HTML><![CDATA[</TD>]]></HTML>
</Fields>
<HTML><![CDATA[</TR>]]></HTML>
</ViewBody>

Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm

Comments

  • Anonymous
    May 18, 2005
    Well this is welcome news (Thanks Mr. Bower, seems Michael doesn&amp;rsquo;t talk to me anymore), another...

  • Anonymous
    August 04, 2005
    I'm really interested in using this feature for our firm's electronic In/Out board. Do you have any additional advice or code examples of how to use the IMNRC feature? We have a SQL table with all of our staff (email, phone extension, etc.), and would like to tie this table to the IMNRC in a SPS/WSS page. Any examples or advice would be greatly appreciated, and we could discuss some compensation for coding work. I can be reached at rthorne@ssandg.com for more details

  • Anonymous
    August 04, 2005
    That is very possible. Essentially you need to emit HTML in your web part calls the IMNRC function around the email address e.g. IMNRC(administrator@somewhere.com'). For a good example, add the members web part to the page and then view the page source in your browser.

  • Anonymous
    March 10, 2006
    Based on the info on the following page:
    http://www.ideseg.com/CategoryView,category,SharePoint-es.aspx

    I added the following to my dvwp list:
                                   <span>
                                       <img border="0" valign="middle" height="12" width="12" src="/_layouts/images/blank.gif" onload="IMNRC('{@Email}')" id="imn{ddwrt:Counter()}" ShowOfflinePawn=1 />
                                   </span>

  • Anonymous
    March 21, 2006
    Any idea why Frontpage modifies calls to {ddwrt:Counter()} to (generate-id}

    This breaks the imnrc functionality when I use it in more than one web part on a page.

  • Anonymous
    October 18, 2006
    Just a little tip as I finally crossed over to the dark side and installed the latest version ofIE7.

  • Anonymous
    January 25, 2007
    Scott Hillier organisiert auf GotDotNet ein Projekt SharePoint 2007 Features das sich zum Ziel gesetzt

  • Anonymous
    March 01, 2007
    Occasionally, I ask SharePoint professionals, who have done interesting and useful work to post a guest

  • Anonymous
    June 01, 2007
    PingBack from http://ansherman892.wordpress.com/2007/06/01/changing-the-theme-when-a-new-sharepoint-2007-site-is-created/

  • Anonymous
    September 19, 2007
    Okay so I found some great info on this site about presence aware stuff: http://blogs.msdn.com/modonovan

  • Anonymous
    September 19, 2007
    Okay so I found some great info on this site about presence aware stuff: http://blogs.msdn.com/modonovan

  • Anonymous
    September 19, 2007
    PingBack from http://www.bloggerloser.com/become-presence-aware-with-your-webparts-with-just-an-email/

  • Anonymous
    September 20, 2007
    This is a great feature - I used it a few months back to query our AD via a web service and create an employee directory right through a DVWP.  I can provide presence information right from MOSS and a status indicator from our LCS server.  We also have our phone system integrated back to LCS so I can even inject URLs to place a call to the person's extention or cell phone which is also brought in from AD right from the directory.  One weird bug I've noticed is the roll-over menu on the LCS pawn seems to break as you scroll down the page.  The roll-over menu appears below the actual entry and moves further down the page the more you scroll.  Very strange - still haven't found a fix for it yet.

  • Anonymous
    September 21, 2007
    PingBack from http://www.bloggerloser.com/become-presence-aware-with-your-webparts-with-just-an-email-2/

  • Anonymous
    November 16, 2007
    Hi I am currently planning to build an employee directory with presence information in our MOSS portal. Some of the approaches I have looked at are: creating a custom list containing user profile information imported into SSP from AD. The only thing is, I haven't been able to figure out how to create a custom list to hold user profile information. Another alternative is one of the comments left about this article about using a DVWP to display information for a web service that directly queries AD. If someone can suggest some alternatives; or, give me some advice on my present options, it would be greatly appreciated. Thank you very much  

  • Anonymous
    January 29, 2008
    Je dérive un peu de mon Axe SharePoint pour m'ouvrir un peu plus sur le Monde IW et dans ce cas, OCS,

  • Anonymous
    February 12, 2008
    PingBack from http://sharepointsherpa.com/2008/02/13/sharepoint-2007-how-to-list/

  • Anonymous
    February 22, 2008
    Klee, I have encountered this problem.  Three factors align to cause it: javascript, css, and the ActiveX control that renders the widget.  I won't try patching the ActiveX control. The javascript problem occurs in init.js in the IMNGetOOUILocation or IMNShowOOUI function.  Certain css rules will alter where the ActiveX widget starts counting the oouiY offset from.  To compensate for the problem in javascript, oouiY should be reduced by document.body.parentNode.scrollTop. To solve the problem with CSS, I can give the body element static positioning then give relative/absolute positioning to a descendant (form#aspnetForm worked for me). Be careful if you muck with the css because MSOLayout_GetRealOffset has problems with some css configurations.  It is used when dragging web parts around the page to reorder them or place them in different zones.  The problem it has is that it ascends the DOM tree by offsetParent and terminates at the body tag.  When your css rules cause the offsetParent to never be the body tag, the loop jumps to the html tag then throws an error looking for the offsetParent.

  • Anonymous
    December 30, 2008
    Does any one knows if one can embed the NameCtrl ActiveX in a non web application ? Any code examples ? I need to embed it in a C++ application. Thanks, Amit

  • Anonymous
    January 23, 2009
    Can IMNRC be used with an Image Web control? How do you set the ShowOfflinePawn attribute?

  • Anonymous
    February 05, 2009
    SharePoint's default Contact Details web part also displays a job title field... Rather than havin to manually input the job title field, is there a way to get IMNRC to auto fill the job title for us?

  • Anonymous
    March 04, 2009
    I need to be able to schedule a live meeting from SharePoint. Can the presence menu be used to show a live meeting link , If yes how. Thanks Akhila

  • Anonymous
    July 22, 2009
    I wanted to remove presence from data view webpart... have any solution please share.. Thanks Nazakath