Thursday 13 February 2014

Server Dependency error (Missing Feature)


          When we redeploy wsp files in sharepoint server, it will check for its previous version using the feature ID. The old versions feature id will not be available since wsp files has been removed. Though the files have been removed its id will be available in the server.

           It will throw an exception and this exception will be stored in the configuration section. When site content backup is restored this error transfers to the other server too. This exceptions can be removed by using power shell command.

          Go to the following location. Central Administration --> Monitoring --> Review Problems and Solutions under Health Analyzer. Under category configuration click Missing Server side dependencies. There you will find [Missing Feature] type. Now go to Sharepoint Power Shell. and do the following.

PowerShell Remove Features in SharePoint because of Health Issue For "Missing Feature"


Run The below power shell Method in SharePoint Management shell.

 function Remove-SPFeatureFromContentDB($ContentDb, $FeatureId, [switch]$ReportOnly)
{
    $db = Get-SPDatabase | where { $_.Name -eq $ContentDb }
    [bool]$report = $false
    if ($ReportOnly) { $report = $true }
   
    $db.Sites | ForEach-Object {
       
        Remove-SPFeature -obj $_ -objName "site collection" -featId $FeatureId -report $report
               
        $_ | Get-SPWeb -Limit all | ForEach-Object {
           
            Remove-SPFeature -obj $_ -objName "site" -featId $FeatureId -report $report
        }
    }
}
function Remove-SPFeature($obj, $objName, $featId, [bool]$report)
{
    $feature = $obj.Features[$featId]
   
    if ($feature -ne $null) {
        if ($report) {
            write-host "Feature found in" $objName ":" $obj.Url -foregroundcolor Red
        }
        else
        {
            try {
                $obj.Features.Remove($feature.DefinitionId, $true)
                write-host "Feature successfully removed from" $objName ":" $obj.Url -foregroundcolor Red
            }
            catch {
                write-host "There has been an error trying to remove the feature:" $_
            }
        }
    }
    else {
        #write-host "Feature ID specified does not exist in" $objName ":" $obj.Url
    }
}



To run only a report (-ReportOnly property):
Remove-SPFeatureFromContentDB -ContentDB "Content_DBName" -FeatureId "e8389ec7-70fd-4179-a1c4-6fcb4342d7a0" –ReportOnly

To remove the feature from all sites, site collections in the db run (no -ReportOnly property):
Remove-SPFeatureFromContentDB -ContentDB "Content_DBName" -FeatureId "8096285f-1473-45c7-85b7-f745e5b2cf29"  


   This will work only for [Missing Feature] issues.

Monday 3 February 2014

XSLT Conditional formatting for sharepoint 2013


<Xsl>
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
  <xsl:include href="/_layouts/xsl/main.xsl"/>
  <xsl:include href="/_layouts/xsl/internal.xsl"/>
  <xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() &gt;= $FirstRow and position() &lt;= $LastRow)]"/>
  <xsl:param name="dvt_apos">&apos;</xsl:param>
<xsl:template name="FieldRef_Hyperlink_URL_body.Details" ddwrt:dvt_mode="body" match="FieldRef[(@Format='Hyperlink') and @Name='Details']" mode="URL_body" ddwrt:ghost="">
    <xsl:param name="thisNode" select="."/>
    <xsl:variable name="url" select="$thisNode/@*[name()=current()/@Name]" />
    <xsl:variable name="desc" select="$thisNode/@*[name()=concat(current()/@Name, '.desc')]" />
    <xsl:choose>
      <xsl:when test="$url=''">
        <xsl:if test="$desc=''">
          <xsl:value-of select="$desc"/>
        </xsl:if>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
<xsl:when test="$desc=''">
              <xsl:value-of select="$url" /></xsl:when>
<xsl:otherwise>
<a href="{$url}"><img alt="Status" src="../../../Style Library/Images/img-icon-discuss.png" border="0" /></a>
</xsl:otherwise>
</xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

<xsl:template name="FieldRef_header.Approvers" ddwrt:dvt_mode="header" match="FieldRef[@Name='Approvers']" mode="header" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)" style="width: 81px">
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="(@Type='User' or @Type='UserMulti') and ($PresenceEnabled='1')">ms-vh</xsl:when>
          <xsl:otherwise>ms-vh2</xsl:otherwise>
         </xsl:choose>
      </xsl:attribute>
      <xsl:call-template name="dvt_headerfield">
        <xsl:with-param name="fieldname">
          <xsl:value-of select="@Name"/>
        </xsl:with-param>
        <xsl:with-param name="fieldtitle">
          <xsl:value-of select="@DisplayName"/>
        </xsl:with-param>
        <xsl:with-param name="displayname">
          <xsl:value-of select="@DisplayName"/>
        </xsl:with-param>
        <xsl:with-param name="fieldtype">
          <xsl:choose>
            <xsl:when test="@Type='Number' or @Type='Currency'">number</xsl:when>
            <xsl:otherwise>x:string</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
    </th>
  </xsl:template>
<xsl:template name="FieldRef_header.Document_x0020_Status" ddwrt:dvt_mode="header" match="FieldRef[@Name='Document_x0020_Status']" mode="header" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)" style="width: 191px">
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="(@Type='User' or @Type='UserMulti') and ($PresenceEnabled='1')">ms-vh</xsl:when>
          <xsl:otherwise>ms-vh2</xsl:otherwise>
         </xsl:choose>
      </xsl:attribute>
      <xsl:call-template name="dvt_headerfield">
        <xsl:with-param name="fieldname">
          <xsl:value-of select="@Name"/>
        </xsl:with-param>
        <xsl:with-param name="fieldtitle">
          <xsl:value-of select="@DisplayName"/>
        </xsl:with-param>
        <xsl:with-param name="displayname">
          <xsl:value-of select="@DisplayName"/>
        </xsl:with-param>
        <xsl:with-param name="fieldtype">
          <xsl:choose>
            <xsl:when test="@Type='Number' or @Type='Currency'">number</xsl:when>
            <xsl:otherwise>x:string</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
    </th>
  </xsl:template>
<xsl:template name="FieldRef_printTableCell_EcbAllowed.Approvers" match="FieldRef[@Name='Approvers']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />
    <td style="width: 81px">
      <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
        <xsl:attribute name="height">100%</xsl:attribute>
        <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
      </xsl:if>
      <xsl:attribute name="class">
        <xsl:call-template name="getTDClassValue">
          <xsl:with-param name="class" select="$class" />
          <xsl:with-param name="Type" select="@Type"/>
          <xsl:with-param name="ClassInfo" select="@ClassInfo"/>
        </xsl:call-template>
      </xsl:attribute>
      <xsl:apply-templates select="." mode="PrintFieldWithECB">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:apply-templates>
    </td>
  </xsl:template>
<xsl:template name="FieldRef_printTableCell_EcbAllowed.Document_x0020_Status" match="FieldRef[@Name='Document_x0020_Status']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />
    <td>
<xsl:attribute name="style">
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Draft in Progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Assigned to 3rd party Lawyer'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Assigned to 3rd Party Lawyer'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Approval in Progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Details) = 'Review in progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Review in progress'" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:cf_explicit="1">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Approver Rejected'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FF0000; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-rejected.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>

<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Reviewer Rejected'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FF0000; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-rejected.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Pending Signature'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: left center;</xsl:if>

<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Pending Signature'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>

<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Not Started'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FAAC32; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/img-icon-inprogress.png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Active'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">background-image: url(&apos;../../../Style Library/Images/img-icon-approved.png&apos;); background-repeat: no-repeat; background-position: right center; font-weight: bold; color: #56C553;</xsl:if>
<xsl:if test="normalize-space($thisNode/@Document_x0020_Status) = 'Over Due'" ddwrt:cf_explicit="1" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">color: #FF0000; font-weight: bold; background-image: url(&apos;../../../Style Library/Images/Overdue(2).png&apos;); background-repeat: no-repeat; background-position: right center;</xsl:if>

</xsl:attribute>

      <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
        <xsl:attribute name="height">100%</xsl:attribute>
        <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
      </xsl:if>
      <xsl:attribute name="class">
        <xsl:call-template name="getTDClassValue">
          <xsl:with-param name="class" select="$class" />
          <xsl:with-param name="Type" select="@Type"/>
          <xsl:with-param name="ClassInfo" select="@ClassInfo"/>
        </xsl:call-template>
      </xsl:attribute>
      <xsl:apply-templates select="." mode="PrintFieldWithECB">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:apply-templates>
    </td>
  </xsl:template>
<xsl:template name="FieldRef_header.Details" ddwrt:dvt_mode="header" match="FieldRef[@Name='Details']" mode="header" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <th nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)" style="width: 69px">
      <xsl:attribute name="class">
        <xsl:choose>
          <xsl:when test="(@Type='User' or @Type='UserMulti') and ($PresenceEnabled='1')">ms-vh</xsl:when>
          <xsl:otherwise>ms-vh2</xsl:otherwise>
         </xsl:choose>
      </xsl:attribute>
      <xsl:call-template name="dvt_headerfield">
        <xsl:with-param name="fieldname">
          <xsl:value-of select="@Name"/>
        </xsl:with-param>
        <xsl:with-param name="fieldtitle">
          <xsl:value-of select="@DisplayName"/>
        </xsl:with-param>
        <xsl:with-param name="displayname">
          <xsl:value-of select="@DisplayName"/>
        </xsl:with-param>
        <xsl:with-param name="fieldtype">
          <xsl:choose>
            <xsl:when test="@Type='Number' or @Type='Currency'">number</xsl:when>
            <xsl:otherwise>x:string</xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
   
    </th>
  </xsl:template>
<xsl:template name="FieldRef_printTableCell_EcbAllowed.Details" match="FieldRef[@Name='Details']" mode="printTableCellEcbAllowed" ddwrt:dvt_mode="body" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:param name="thisNode" select="."/>
    <xsl:param name="class" />
    <td style="width: 69px">
      <xsl:if test="@ClassInfo='Menu' or @ListItemMenu='TRUE'">
        <xsl:attribute name="height">100%</xsl:attribute>
        <xsl:attribute name="onmouseover">OnChildItem(this)</xsl:attribute>
      </xsl:if>
      <xsl:attribute name="class">
        <xsl:call-template name="getTDClassValue">
          <xsl:with-param name="class" select="$class" />
          <xsl:with-param name="Type" select="@Type"/>
          <xsl:with-param name="ClassInfo" select="@ClassInfo"/>
        </xsl:call-template>
      </xsl:attribute>
      <xsl:apply-templates select="." mode="PrintFieldWithECB">
        <xsl:with-param name="thisNode" select="$thisNode"/>
      </xsl:apply-templates>
    </td>
  </xsl:template>
</xsl:stylesheet></Xsl>