Introduction

This blog is mainly focused on SharePoint
I will use this to store and share all the tips and tricks about SharePoint and the related products
List of all posts

Eric Fang's SharePoint Boat: How to get user information in InfoPath web form programmatically?


Topic Getting user information in InfoPath
Output AccountId, DisplayName, email, Manager, Busness Unit, etc

Step Description
Link A really helpfull psot by Eric Fang about it can be find here : Eric Fang's SharePoint Boat: How to get user information in InfoPath web form programmatically?

xsl template : Adding calculation in a group header


Topic xsl template : Adding calculation in a group header
Output Groupe Name + Result of formula

Step Description
1 Create the template
<xsl:template name="FieldRef_Text_body.Display_x0020_Name" ddwrt:dvt_mode="body" match ="FieldRef[@Name='Display_x0020_Name']" mode="Text_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:choose>
     <xsl:when test="@AutoHyperLink='TRUE'">
   <xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping ="yes"/>
  </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="$thisNode/@*[name()=current()/@Name]"/></xsl:otherwise>
    </xsl:choose>
 </xsl:template>
this is the default template create by sharepoint 2010
2 Add the calculation part (after param and before choose) 1° we will store in a variable the selection criterium for the calculation
<xsl:variable name="cname" select="$thisNode/@Display_x0020_Name" />
2° we will select only the rows that match our criterium in the calculation
<xsl:variable name="WD select="sum($Rows/Row[@Display_x0020_Name = $cname]/@Work_x0020_Days)"/>
3Add the calculation result (after the xsl:choose closing tag
<xsl:value-of select="$WD"/>
4If you want to add space between info, just add the following
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">&nbsp;</xsl:text>

xsl template : change the display format of a date


Topic xsl template : change the display format of a date
Output DD/MM/YYYY

Step Description
1 Create the main transformation template
 <xsl:template name="Tz_Date" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
     <xsl:param name="thisNode" />
    <script type="text/javascript">
 var sdate = '<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" />';
 if (sdate.length > 6)
 document.write(sdate.split('/')[1] + '/' + sdate.split('/')[0] + '/' + sdate.split('/')[2]);
 </script>
</xsl:template>
2 Create template that match all the fields who need to be transformed
 <xsl:template name="Format_Begin_x0020_Date" ddwrt:dvt_mode="body" match ="FieldRef[@Name='Begin_x0020_Date']" mode="DateTime_body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
     <xsl:param name="thisNode" select="."/>
     <xsl:call-template name="Tz_Date"><xsl:with-param name="thisNode" select="$thisNode"/></xsl:call-template>
  </xsl:template>
3Repeat step 2 for each field match needed

by Category