How to get the username from a field which is defined as "Name (with presence)"

Stef Heyenrath
  • How to get the username from a field which is defined as "Name (with presence)" Stef Heyenrath

    In a custom list there is a column / field defined as “Name (with presence)”.

    In my modified aspx page, I want to do an ‘xsl if’ statement to check if the value from this field is the same as the current user.

    <xsl:if test="@MyField = $UserID">
        ... code here ...
    </xsl:if>
    

    But the compare fails because the content from the MyField is something like :

     <span>
               <A HREF="/sites/121579/MySite/_layouts/userdisp.aspx?ID=452">***, Stef</A>
               <img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/>
               <a href='javascript:' onclick='IMNImageOnClick();return false;' class='ms-imnlink'>
                      <img name='imnmark' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' sip='stef.***@***.com' id='imn_998,type=smtp'/>
               </a>
        </span>
    

    And not just “***, Stef”

  • Solution is very simple.

    Don’t do test on 'equals'

    <xsl:if test="@MyField = $UserID">
        ... things here ...
    </xsl:if>
    



    But a test on 'contains' (Just check if the field ‘MyField’ contains the value from $UserID)

    <xsl:if test="contains(@MyField, $UserID)">
        ... things here ...
    </xsl:if>
    

Tags
xslt
Related questions and answers
  • Hiding Left Nav user1155

    ="LeftNavTableCell" runat="server"&gt; &lt;table cellpadding="0" cellspacing="0" id="LeftNav"&gt; &lt;tr> &lt;td style="width:301px; text-align:left; vertical-align:top...="0" cellspacing="0" border="0"&gt; &lt;tr> &lt;td> &lt;table class="ms-navheader" width="100%" cellpadding="0" cellspacing="0" border="0"&gt; &lt;tr> &lt;td nowrap="nowrap" id="idSiteHierarchy"&gt; &lt;SharePoint:SPLinkButton runat="server

  • :call-template name="dvt_1.header"&gt; &lt;xsl:with-param name="Rows" select="$Rows" /&gt; &lt;/xsl:call-template> &lt;table border="0" width="100%"&gt; &lt...;xsl:param name="Pos" /&gt; &lt;tr> &lt;td> &lt;table border="0" cellspacing="0" width="100%"&gt;&lt;tr>&lt;td class="ms-formlabel" valign="top" nowrap="true...; &lt;xsl:param name="dvt_RowCount" /&gt; &lt;xsl:param name="RealLastRow" /&gt; &lt;table cellspacing="0" cellpadding="4" border="0" width="100%"&gt; &lt;tr>

  • (this, event));"&gt;&lt;NOBR>&lt;IMG style="VERTICAL-ALIGN: middle" alt="" src="http://spdev/_layouts/inc/contactPickerSelectNames.png?rev=azqd2BNDQfZJX%2Bi5rXdMhQ%3D%3D"&gt; &lt;SPAN style="VERTICAL-ALIGN: middle"&gt;Кому: &lt;/SPAN>;&lt;/NOBR>&lt;/BUTTON>&lt;/TD> &lt;TD style="WIDTH: 100%"&gt;&lt;SPAN onmouseover="return... (ContactPicker.OnEditBoxFocus(this, event));" title="" tabIndex=0&gt;&lt;/DIV>&lt;/DIV>&lt;/SPAN>;&lt;/TD> &lt;TD vAlign=top>&lt;BUTTON id=V1_I1_CP2_ResolveButton onfocus="return

  • " cellspacing="0" cellpadding="0" class="bgTop"&gt; &lt;tr> &lt;td align="center"&gt; &lt;table width="579" height="108" border="0" cellspacing="0" cellpadding="0" class="header"&gt; &lt;tr> &lt;td>&lt;img src="http://URLtomylogo.jpg" width="579" height="108" alt="Logo"/&gt; &lt;/td> &lt;/tr>..." height="108" border="0" cellspacing="0" cellpadding="0" class="bgBottom"&gt; &lt;tr> &lt;td align="center"&gt; &lt;table width="559" height="88" border="0

  • , but that ends up rendering the actual anchor tag, as opposed to a clickable hyperlink: &lt;a href="http://www.something.com"&gt;www.something.com&lt;/a>; So then I tried creating a XSL transform, since...;a href="{$url}"&gt;&lt;xsl:value-of select="$url"/&gt;&lt;/a>; &lt;/xsl:template> &lt;/xsl:stylesheet> ...="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal"&gt; &lt;xsl:template match="FieldRef[@FieldType='DataLinkUrl']" mode="Note_body"&gt; &lt;xsl:param name="thisNode" select="."/&gt; &lt;xsl

  • ','')} } }); }); &lt;/script>&lt;div id="dialog" title="Question" style="display:none"&gt;&lt;span>;&lt;/span>;&lt;span>;What is the Capital of Massachusetts ?&lt;/span>;&lt;table id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02" border="0"&gt; &lt;tr> &lt;td>&lt;input id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_0...; &lt;td>&lt;input id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_2" type="radio" name="ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$ctl02" value="3" /&gt;&lt;label for="ctl00_m

  • /@Distance[1]"/&gt;&lt;/xsl:call-template> &lt;xsl:template name="xsum"&gt; &lt;xsl:param name="currnode"/&gt; &lt;xsl:param name="res" select="0"/&gt; &lt;xsl..." select="'Distance'"/&gt; &lt;xsl:with-param name="res" select="0"/&gt; &lt;/xsl:call-template> km &lt;xsl:template name="xsum"&gt; &lt;xsl:param name="currnode"/&gt; &lt;xsl:param name="attr-type"/&gt; &lt;xsl:param name="res" select="0"/&gt; &lt;xsl:choose> &lt;xsl:when test="$currnode/following-sibling::Row"&gt

  • ;/Description> &lt;IsIncluded>true</IsIncluded> &lt;ZoneID>Main</ZoneID> &lt;PartOrder>0&lt;/PartOrder> &lt;FrameState>Normal</FrameState> &lt;Height /&gt; &lt;Width /&gt; &lt;AllowRemove>true</AllowRemove> &lt;AllowZoneChange>true</AllowZoneChange> &lt;AllowMinimize>true</AllowMinimize> &lt;AllowConnect>true<...;/HelpMode> &lt;Dir>Default</Dir> &lt;PartImageSmall /&gt; &lt;MissingAssembly>Cannot import this Web Part.&lt;/MissingAssembly> &lt;PartImageLarge>/_layouts/images/mscontl.gif&lt

  • Name = "ItemName" /&gt; &lt;HTML>&lt;![CDATA[&lt;/a>;&lt;br/&gt;Thank You<br/&gt;]]&gt;&lt;/HTML> &lt;/Case> &lt;Case Value = "2"&gt... Name="DisplayName#{Field}" HTMLEncode="TRUE" /&gt; &lt;HTML>&lt;![CDATA[ : ]]&gt;&lt;/HTML> &lt;GetVar Name="NewValue#{Field}" /&gt; &lt...I've customized alert notification template for Announcements list. Here is custom code: &lt;Immediate> &lt;Subject> &lt;Switch> &lt;Expr> &lt;GetVar Name

Data information