Presence and user profile URL with XSLT

When showing a person field, the field does not show the presence and there is no link to the users My site. With XSLT it is possible to show the prensence of the user and create a URL to the users My Site.

Solution showing the presence 

1. Open the ItemStyle.xsl in SharePoint Designer.
2. Add the reference to the header of the XSLT file, if the reference is missing.

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

3.  Add the following code to the XSLT template.

<xsl:variable name="UserEmail">
   <xsl:value-of select="ddwrt:UserLookup(string(@UserField) ,'EMail')" />
</xsl:variable>

<img width="12" height="12" id="{generate-id(@UserField)}" onload="IMNRC('{$UserEmail}');" alt="UserPresence" src="/_layouts/images/blank.gif" border="0" complete="complete" Sortable="1" valign="middle"/>

4. Change the @UserField to your user field.

Solution creating the user profile URL

1. Open the ItemStyle.xsl in SharePoint Designer.
2. Add the reference to the header of the XSLT file, if the reference is missing.

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

3. Add the following code to the XSLT template.

<xsl:variable name="UserFieldLogin">
   <xsl:value-of select="ddwrt:UserLookup(string(@UserField) ,'Login')" />
</xsl:variable>

<a href="https://my.macaw.nl/Person.aspx?accountname={$UserFieldLogin}"> 
<xsl:value-of select="@UserField"/></a>

4. Change the @UserField to your user field.
5. Change the My Site example URL to your My Site URL.

<a href="https://my.macaw.nl/Person.aspx?accountname={$UserFieldLogin}">


Result

Share

11 Replies to “Presence and user profile URL with XSLT”

    1. I resolved the problem. Users, who not exist in SPUsers for site, not have ID. Ben Prins, thanks for reply.

  1. Hi,

    We have a column in a list which is people type. We have crawled this for search.

    Our requirement is to show that column with user presence in the search result item.

    Is it possible to implement the same with Search Display Templates in SharePoint 2013

    Thank you !

    Regards,
    Joseph

  2. I don’t think you can use XSLT within the news Search Display Templates. But it must be possible to create an Search Display Template that displays the users presence. You might be able to copy this functionality from the default Search Display Template used for the people search results.

  3. Hi Ben,

    thanks for your solution.

    Everything works fine with one exception:
    – The image container doesnt show the colors green = online; yellow.., red…

    Do you have a solution for this behavior. (We are using SP2013)

    Thank you,

    Konstantin

  4. Are you logged into Lync? When lync is offline you will not see the presence of users. This might be the issue.

  5. Hi, you don’t have to use a custom xlst for some applications. Simply use “Name (and presence)” when you configure the list field “person”.

Leave a Reply to Konstantin Riegel Cancel reply

Your email address will not be published.