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
Works only for current user. Why? Help me, please
I will need a bit more information to be able to help you. Can you send me you XSLT?
I have tried to use your URL, without any success. Do you get the same problem when using an URL to the users My Site?
I resolved the problem. Users, who not exist in SPUsers for site, not have ID. Ben Prins, thanks for reply.
You’re welcome.
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
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.
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
Are you logged into Lync? When lync is offline you will not see the presence of users. This might be the issue.
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”.