Get both ID and Name from a User type field in a cqwp

1.2k Views Asked by At

I'm building a Content Query Web Part that is supposed to show a link to a user page. I get the user name from a custom list containing a column named 'Member' of the type 'Person or Group'. To build the link in the ItemStyle.xsl, I need both the name and the Id of the user:

<a href="http://<site>/_layouts/userdisp.aspx?ID=@ID">
    <xsl:value-of select="@Member" />
</a>

However, I'm only able to get the name OR the Id from the Content Query. E.g. if I set "Show field: Name (with presence)" for the Member column I get the name, and if I set "Show field: ID" I obviously get the Id. But I need both!

I've done some quite extensive googling, but I haven't been able to find an answer. The closest I've came is this:

http://social.technet.microsoft.com/Forums/en-US/e6a29bf0-82de-46b1-896a-9d45c8fd527f/sharepoint-2010-cqwp-how-to-get-the-user-id-from-a-user-field-type-value?forum=sharepointgeneralprevious

but the reply is not satisfactory to my needs. Any help or ideas would be greatly appreciated!

1

There are 1 best solutions below

0
On

Using XSL, I can do this:

<xsl:if test="@Contact.title != ''">
  <xsl:value-of select="@Contact" disable-output-escaping="yes"/>
</xsl:if>

This gives me the link to user profile page with name (equivalent of anchor with name displayed).

I know this question is several months old, hopefully this helps someone. But I came to this link because I am trying to do the same(get id and Name using JSOM). I still don't have the answer.