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>

Tuesday, 7 January 2014

Default permission levels in Sharepoint 2013

SharePoint 2013 includes seven permission levels:

- View Only: It enables users to view application pages.

- Limited Access: It enables users to access shared resources and a specific asset. Limited Access cannot be edited or deleted.

- Read: It enables users to view pages and list items, and to download documents.

- Contribute: Contribute enables users to manage personal views, edit items and user information, delete versions in existing lists and document libraries, and add, remove, and update personal Web Parts.

- Edit: It enables users to manage lists.

- Design: Design permission level enables users to view, add, update, delete, approve, and customize items or pages in the website.

- Full Control: It enables users to have full control of the website.

Apart from this SharePoint 2013 also provides some permission levels to templates other than team site template. These are below:

- Restricted Read: This permission level is only for Publishing sites only. It enables View pages and documents.

- Approve: This permission level is only for Publishing sites only. It enables Edit and approve pages, list items, and documents.

- Manage Hierarchy: This permission level is only for Publishing sites only. Create sites; edit pages, list items, and documents, and change site permissions.

Thursday, 2 January 2014

Deleting error webpart without using designer


          I was using a ReportViewerWebPart webpart at my home page. Sometimes during deployment this cause trouble that i could not open my home page since in some servers reports was not configured. I was resolving it using Sharepoint designer. I would open up my home page with sharepoint designer delete the webpart and now i could open my home page.

         Now i have found an alternate solution for this. We could use Web Part Page Maintenance for deleting this error web part. The solution is,

Procedure:

     Add the value ?Contents=1 at the end of your site.

     It now looks like http://yourservername/sites/yoursitename?Contents=1

     Hit Enter, that leads you to webpart maintenance page.

        
  The "Open on Page" shows error if that webpart contains error. you can select that particular webpart and delete it.

     Now the error webparts in homepage is deleted and the home page is displayed without the error webparts.

Monday, 30 December 2013

Hide Quick Launch in Sharepoint 2013


         Earlier in my post , http://prasath04sharepoint.blogspot.in/2013/05/hide-top-bar-ribbon-quick-launch-in.html we had took a look on hiding quick launch controls in sharepoint 2010. Unfortunately this method doesn't work with Sharepoint 2013.

For hiding quick launch at Sharepoint 2013 we have to use different css.

To hide only Quick Launch Panel from the view

Add the following css code in the Application Page under PlaceHolderMain section.

<style type="text/css">
 #sideNavBox {DISPLAY: none}
 #contentBox {MARGIN-LEFT: 5px}
</style>

Tuesday, 17 December 2013

Get Current User Email by sharepoint 2013 Object Model


Hi,


   Here we will write sharepoint 2013 object model code to retrieve current user email id. 
Use the following code.

string strUserName = HttpContext.Current.User.Identity.Name.ToString();

string strEmail = SPContext.Current.Web.AllUsers[strUserName].Email;

First we will retrieve the user name and then we will retrieve the email id.

Automation of Reports(Send reports as mail regularly)


Hi,


    I was always wondering weather i could automate reports in Sharepoint. My idea is, rather than viewing the reports from sharepoint site what if i get a daily reports by mail ? Here is the procedure on how to configure to get a daily reports via mail.

For this purpose you need a working report in shareopint site.

Choose , Microsoft SQL Server 2008 r2 à  Configuration Tools à Reporting Service Configuration Manager





















The Reporting Service Configuration Connection opens up. Ensure correct Server  Name and Report Server Instance and click Connect.


Choose E-mail Settings and provide your outgoing mail address and your server name. Click Apply and save changes.



Now point dropdown at your report and choose "Manage Subscriptions".


Click on Add Subscription.





On the To Section provide the mail address for whom the report has to be sent as mail. Also you can configure appropriate time during which the report will be delivered. In Report Contents section you can also choose the format that you wish to deliver the report(PDF, World, Excel, MHTML etc..,). Click ok and you can find the subscription is added to the report and is available.


This will deliver the report as mail to the particular mail id that was mentioned.









Monday, 16 December 2013

Different types in Updating Sharepoint List


            While creating Event Receivers or Workflows we need to update the list or list items using SPListItem method. However there are different types in updating. Most commonly used are Update and SystemUpdate. lets see the different types of updates and its use.


Update()


  • Updates the item in the database.
  • Updates the “Modified” and “Modified by” values.
  • Creates a new version.

Systemupdate()


  • Updates the item in the database(List).
  • Does not update build in columns "Modified" and "Modified By".
  • Does not increment item version.
  • Triggers the item events.

Systemupdate(true)


  • Updates data to database(List).
  • Does not update build in columns "Modified" and "Modified By".
  • Will increment Item Version.

Systemupdate(false)


  • Updates data to database.
  • Does not update build in columns "Modified" and "Modified By".
  • Does not increment item version.

UpdateOverwriteVersion()


  • Updates data to database.
  • Updates build in columns "Modified" and "Modified By".
  • Does not increment new version.

Note :


You can also disable the triggering of events by using “this.EventFiringEnabled = false;”. Do your update and enable the events again with “this.EventFiringEnabled = true;”