SP Workflow Stages

If you are using SharePoint Workflows the system stores a digital value instead of the text value.

Status Value
Not Started 0
Failed on Start 1
In Progress 2
Error Occurred 3
Canceled 4
Completed 5
Failed on Start (retrying) 6
Error Occurred (retrying) 7
Canceled 15
Approved 16
Rejected 17

SiteManager

SiteManager is still available on SharePoint 2013.

_layouts/sitemanager.aspx

DataViewWebpart in matrix display with XSLT modifications

Starting point:

  • SharePoint document library with documents
  • Documents use Category: Global, Regional and Local
  • Each document use a title. Needed for grouping.
  • Calculated-Column to generate a sorting order

Objective point:

  • Documents should be arrange in a matrix.
  • Header column displays the category
  • One document with the same title will and different categories should be display in one row.

Solution:

  • Using SharePoint Designer
  • Adding new DataView WebPart
  • Modify the XSLT

<xsl:template name=”dvt_1″>
<xsl:variable name=”dvt_StyleName”>2ColFrm</xsl:variable>
<xsl:variable name=”Rows” select=”/dsQueryResponse/Rows/Row” />

<xsl:variable name=”dvt_RowCount” select=”count($Rows)” />
<xsl:variable name=”dvt_IsEmpty” select=”$dvt_RowCount = 0″ />
<xsl:choose>
<xsl:when test=”$dvt_IsEmpty”>
<xsl:call-template name=”dvt_1.empty” />
</xsl:when>
<xsl:otherwise>
<table width=”100%” border=”1px” cellpadding=”0″ cellspacing=”0″>
<tr>
<th style=”padding: 4px;”>Product name</th>
<th style=”padding: 4px;”>Global</th>
<th style=”padding: 4px;”>Regional</th>
<th style=”padding: 4px;”>Local</th>
</tr>

<xsl:call-template name=”dvt_1.body”>
<xsl:with-param name=”Rows” select=”$Rows” />
</xsl:call-template>

</table>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name=”dvt_1.body”>
<xsl:param name=”Rows” />
<xsl:for-each select=”$Rows[@txtIWCOrder != ”]”>
<xsl:sort select=”@txtIWCOrder” />
<xsl:call-template name=”dvt_1.rowview” />
</xsl:for-each>

</xsl:template>

<xsl:template name=”dvt_1.rowview”>
<xsl:variable name=”pos” select=”position()”/>
<!–<xsl:variable name=”previewItemID”><xsl:value-of select=”substring-after(preceding-sibling::*[1]/@txtIWCOrder, ‘#’)”/></xsl:variable>–>
<xsl:variable name=”previewItemName”><xsl:value-of select=”substring-before(preceding-sibling::*[1]/@txtIWCOrder, ‘#’)”/></xsl:variable>
<xsl:variable name=”nextItemName”><xsl:value-of select=”substring-before(following-sibling::*[1]/@txtIWCOrder, ‘#’)”/></xsl:variable>
<!–<xsl:variable name=”nextItemID”><xsl:value-of select=”substring-after(following-sibling::*[1]/@txtIWCOrder, ‘#’)”/></xsl:variable>–>
<xsl:variable name=”currentItemID”><xsl:value-of select=”substring-after(@txtIWCOrder,’#’)”/></xsl:variable>
<xsl:variable name=”currentItemName”><xsl:value-of select=”substring-before(@txtIWCOrder,’#’)”/></xsl:variable>

<xsl:choose>
<xsl:when test=”position()=1″>
<xsl:text disable-output-escaping=”yes”>&lt;tr class=”Beginn”&gt;</xsl:text>
<td style=”padding:4px;”>
<xsl:value-of select=”@Title” disable-output-escaping=”yes”/>
</td>

<xsl:choose>
<xsl:when test=”$currentItemID = 1″>
<td  align=”center”><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>
<xsl:if test=”$nextItemName !=$currentItemName”><td  align=”center”>-</td></xsl:if>
<xsl:if test=”$nextItemName !=$currentItemName”><td  align=”center”>-</td></xsl:if>
</xsl:when>
<xsl:when test=”$currentItemID = 2″>
<td  align=”center”>-</td>
<td  align=”center”><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>
<xsl:if test=”$nextItemName !=$currentItemName”><td  align=”center”>-</td></xsl:if>
</xsl:when>
<xsl:when test=”$currentItemID = 3″>
<td  align=”center”>-</td>
<td  align=”center”>-</td>
<td  align=”center”><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>
</xsl:when>
</xsl:choose>

</xsl:when>
<xsl:when test=”$currentItemName = $nextItemName”>
<!– n-node –>
<xsl:text disable-output-escaping=”yes”>&lt;tr class=”Equal”&gt;</xsl:text>
<td class=”Equal” style=”padding:4px;”>
<xsl:value-of select=”@Title” disable-output-escaping=”yes”/>
</td>
<td class=”multiple-CurNext”  align=”center”><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>

</xsl:when>
<xsl:when test=”$currentItemName != $nextItemName”>
<xsl:if test=”$currentItemName != $previewItemName”>
<xsl:text disable-output-escaping=”yes”>&lt;tr class=”Single”&gt;</xsl:text>
<td style=”padding:4px;”>
<xsl:value-of select=”@Title” disable-output-escaping=”yes”/>
</td>

<xsl:choose>
<xsl:when test=”$currentItemID = 1″>
<td  align=”center”><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>
<xsl:if test=”$nextItemName !=$currentItemName”><td  align=”center”>-</td></xsl:if>
<xsl:if test=”$nextItemName !=$currentItemName”><td  align=”center”>-</td></xsl:if>
</xsl:when>
<xsl:when test=”$currentItemID = 2″>
<td  align=”center”>-</td>
<td  align=”center”><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>
<xsl:if test=”$nextItemName !=$currentItemName”><td  align=”center”>-</td></xsl:if>
</xsl:when>
<xsl:when test=”$currentItemID = 3″>
<td  align=”center”>-</td>
<td  align=”center”>-</td>
<td  align=”center”><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>
</xsl:when>
</xsl:choose>

<xsl:text disable-output-escaping=”yes”>&lt;/tr&gt;</xsl:text>
</xsl:if>

<xsl:if test=”$currentItemName = $previewItemName”>
<!– Only table section headline –>
<xsl:if test=”$currentItemName = $nextItemName”>
<xsl:text disable-output-escaping=”yes”>&lt;tr class=”Multiple”&gt;</xsl:text>
<td style=”padding:4px;”> <xsl:value-of select=”@Title” disable-output-escaping=”yes”/>
</td>
</xsl:if>
<td  class=”multiple” align=”center” ><a href=”{@FileDirRef}/{@FileLeafRef}” title=”{@Title} – {@Category}”>X</a></td>

<xsl:if test=”$currentItemName != $nextItemName”>
<td  class=”multiple-empty” align=”center”>-</td>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:if test=”position() = last()”>
<xsl:text disable-output-escaping=”yes”>&lt;/tr&gt;</xsl:text>
</xsl:if>
</xsl:template>

Create SPGroups with PowerShell

You can create via PowerShell SharePoint Groups for a specific SiteCollection.

$siteURL = “http://intramania.com/sites/mysitecollection
$web = Get-SPWeb $siteURL
$groups = $web.SiteGroups
$groups.Add(“My-Group-Name-01”, $web.CurrentUser, $null, “SharePoint Group Name 01”)
$groups.Add(“My-Group-Name-02”, $web.CurrentUser, $null, “SharePoint Group Name 02”)
$groups.Add(“My-Group-Name-03”, $web.CurrentUser, $null, “SharePoint Group Name 03”)
$groups.Add(“My-Group-Name-04”, $web.CurrentUser, $null, “SharePoint Group Name 04”)
$groups.Add(“My-Group-Name-05”, $web.CurrentUser, $null, “SharePoint Group Name 05”)

PowerShell: Get creation date of all Site Collection in farm

Get creation date of all site collections in all Web-applications:

$Sites=@();
Get-SPSite -limit ALL|%{
$RootWeb = $_.RootWeb;
$Created = $RootWeb.Created;
$Sites += New-Object PSObject -Property @{SiteUrl=$RootWeb.Url; Created=$Created}
write-host $Sites
$RootWeb.Dispose();
$_.Dispose();
}
$Sites|Export-CSV “C:\SiteCollectionCreated.csv” -NoTypeInformation;

Set Date with EventReceiver

properties.AfterProperties[“ApprovedTimeStamp”] = DateTime.Now.ToString(“yyyy-MM-ddTHH:mm:ssZ”); // Works Fine

properties.AfterProperties[“ApprovedTimeStamp”] = Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now); // Works Fine