Saturday, January 8, 2011

How to estimate the storage space required for SharePoint 2010 content databases and Index servers?

Scenario:
How to estimate the storage space required for SharePoint 2010 content databases and index servers?

Explanation:

The following process describes how to approximately estimate the storage required for content databases, without considering log files:
1.   Calculate the expected number of documents. This value is referred to as D in the formula.

How you calculate the number of documents will be determined by the features that you are using. For example, for My Site Web sites or collaboration sites, we recommend that you calculate the expected number of documents per user and multiply by the number of users. For records management or content publishing sites, you may calculate the number of documents that are managed and generated by a process.

If you are migrating from a current system, it may be easier to extrapolate your current growth rate and usage. If you are creating a new system, review your existing file shares or other repositories and estimate based on that usage rate.
2.   Estimate the average size of the documents that you will be storing. This value is referred to as S in the formula. It may be worthwhile to estimate averages for different types or groups of sites. The average file size for My Site Web sites, media repositories, and different department portals can vary significantly.
3.   Estimate the number of list items in the environment. This value is referred to as L in the formula.

List items are more difficult to estimate than documents. We generally use an estimate of three times the number of documents (D), but this will vary based on how you expect to use your sites.
4.   Determine the approximate number of versions. Estimate the average number of versions any document in a library will have (this value will usually be much lower than the maximum allowed number of versions). This value is referred to as V in the formula.

The value of V must be above zero.
5.   Use the following formula to estimate the size of your content databases:

Database size = ((D × V) × S) + (10 KB × (L + (V × D)))

The value of 10 KB in the formula is a constant that roughly estimates the amount of metadata required by SharePoint Server 2010. If your system requires significant use of metadata, you may want to increase this constant.
As an example, if you were to use the formula to estimate the amount of storage space required for the data files for a content database in a collaboration environment with the following characteristics, you would need approximately 105 GB.
Input
Value
Number of documents (D)
200,000
Calculated by assuming 10,000 users times 20 documents
Average size of documents (S)
250 KB
List items (L)
600,000
Number of non-current versions (V)
2
Assuming that the maximum versions allowed is 10
Database size = (((200,000 x 2)) × 250) + ((10 KB × (600,000 + (200,000 x 2))) = 110,000,000 KB or 105 GB

Microsoft recommends 80 GB of hard disk space for WFE servers. Maintain twice as much free space as you have RAM for production environments.

A quick formula to calculate the hard disk space on the index server would be to multiply the expected index-able content by 20%.

So for example if the expected total content to be indexed is 500 GB, the index server needs at least 500 * 20% = 100GB

This white paper from Microsoft explains how to estimate performance and capacity requirements for SharePoint in more detail. (page 45 for specific guidance on how to calculate storage needs for search)
 

How to enable VariationLabelMenu control in SharePoint 2010?

Scenario: 
How to enable VariationLabelMenu control in SharePoint 2010?

Explanation:
SharePoint 2010 (and MOSS 2007) ships with a control called VariationLabelMenu that can be used on sites with site variations enabled. This control enables users to navigate to the related/equivalent pages in other language sites (for which the language packs are installed)

Even though this control is provided OOB in SharePoint 2010, few steps need to be followed to get it to work.

After everything has been configured correctly, you will see a nice little menu that looks like in the below picture. You can place it in the master page or page layout according to your needs.


In my case, I have german language pack installed and therefore the VariationLabelMenu control displays "Deutsch" in the dropdown options.

Solution:

Step-1: 
Go to the location Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES, find the file "VariationsLabelMenu.ascx" and edit it.
Add the below line to the contents of the file.

<cms:VariationsLabelEcbMenu id ="varlabelmenu1" DataSourceID="LabelMenuDataSource" DisplayText="Links" IsCallbackMode="true" runat="server" />






After this change, the VariationLabelMenu shows up in the ribbon but it messes up with the existing controls in the ribbon which is not very pleasant.

There are some side effects due to the above change. The page editing options in the ribbon menu gets shrunk as the ribbon needs to accommodate the "VariationLabelMenu" control.


As you can notice in the above picture, the page editing options have been messed up.
Ideally it should look like below:


Also the welcome control that displays the Personal Actions Menu (Welcome Menu) will be replaced with the VariationLabelMenu control as shown below:



From what I have noticed, the reason for the disappearance of the welcome menu and the improper displayof the page editing options in the ribbon are because of the VariationLabelMenu. So if we hide it in the ribbon and show it somewhere else on the page, things will look normal again.

I have searched for the VariationLabelMenu control's markup in the HTML generated by SharePoint. In my case, it is ctl00_ctl34_varlabelmenu1. The control ID may change depending on your master page settings.

<style type="text/css">
    #ctl00_ctl34_varlabelmenu1 {display:none;}
</style>

Include the above code any where in the master page / page layout and it will hide the VariationLabelMenu control in the ribbon.

Now it's time to add the VariationLabelMenu control somewhere else on the page.
Add the below line of code at the top of the master page.

<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>

Find an appropriate location in the master page / page layout and add the below line of code which renders the VariationLabelMenu on the page.

<PublishingVariations:VariationsLabelMenu id="labelmenu1" runat="server"/>

Thursday, January 6, 2011

How to show the published date for a SharePoint blog post in Content Query Web Part?

Questions:

What is the difference between the fields PubDate and PublishedDate in a SharePoint Blog Post content type?

How to display a SharePoint blog post's PublishedDate in Content Query Web Part ?

Explanation:

If you try to use Content Query Web Part hereafter referred to as CQWP to pull blog posts, you will notice that CQWP by default pulls the following fields:
  • Modified
  • Created
  • PubDate
It quite looks like the field "PubDate" refers to the date on which the blog post was published.
But in fact the "PubDate" field is the same as the field "Modified" except that it returns the date in a different format.

Friday, November 19, 2010

How to make an _layouts page (application page) in SharePoint anonymous?

Scenario:
How to make an _layouts page (application page) in SharePoint anonymous?

Explanation:
The application pages (custom pages that are created inside the layouts folder) in SharePoint  will ask for authentication even when a user tries to access them from a site that is configured for anonymous access (public facing site).

Resolution:

  • Make sure that the application page is inherited from "Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase"
  • Override the AllowAnonymousAccess property and return true
If the application page does not have code-behind, the below snippet will mark the property "AllowAnonymousAccess" to true:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" DynamicMasterPageFile="~masterurl/default.master" %>
<script runat="server" type="text/C#">
protected override bool AllowAnonymousAccess
{  
    get
    {  
        return true;  
    }  
}
</script>

If the application page has code-behind, the below snippet will mark the property "AllowAnonymousAccess" to true:

public class ApplicationPage :  Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase
{
  protected override bool AllowAnonymousAccess { get { return true; }
}

Tuesday, November 16, 2010

How to repair corrupt SPWebConfigModification Objects in SharePoint?

Scenario: How to repair corrupt SPWebConfigModification objects?

Explanation: Recently I worked on automating web.config deployments through PowerShell and during that process, I have ended up corrupting the SPWebConfigModification objects several times.

An indication of corrupted SPWebConfigModification objects is the generic exception "Object reference not set to instance of an object" when you try to make any changes to web.config using SPWebConfigModification class from code.

The below steps could be followed to fix the corrupted SPWebConfigModification objects:

Navigate to the table "Objects" in database "SharePoint_Config" and run the below script:

SELECT    Id, ClassId, ParentId, Name, Status,  Version, Properties
FROM        Objects
WHERE    (Name LIKE '%WebConfig%') 

In order to make any updates this table, we will need to disable the triggers on it.
By default,  the table "Objects" has the following triggers attached to it:
  • trigger_OnDeleteObjects
  • trigger_OnTouchObjects


DISABLE TRIGGER [dbo].[trigger_OnDeleteObjects] ON Objects
DISABLE TRIGGER [dbo].[trigger_OnTouchObjects] ON Objects

Perform an IISRESET.

Identify the corrupted row and delete it.

I have also tried to modified the corrupted item but it did not work
out. 

Enable triggers on the Objects table:

ENABLE TRIGGER [dbo].[trigger_OnDeleteObjects] ON Objects
ENABLE TRIGGER [dbo].[trigger_OnTouchObjects] ON Objects

Reference: thekid.me.uk

Friday, October 1, 2010

How to apply the SharePoint site's default master page on an application page (page in _layouts folder)

Scenario: How to apply the SharePoint site's default master page on an application page (page in _layouts folder)

Explanation: When we try to change the master page (~/_layouts/application.master) for an application page, SharePoint would not allow that change to happen.

Simple work around would be to change the master page in the "OnPreInit" event of the application page

A simple inline script would do the job:

<script runat="server">
protected override void OnPreInit(EventArgs e)
{
  base.OnPreInit(e);
  this.MasterPageFile = SPContext.Current.Web.MasterUrl;
}
</script> 

Complete code for the application page looks like the below:

<script runat="server">
protected override void OnPreInit(EventArgs e)
{
  base.OnPreInit(e);
  
  //This is where you set the master page to be used by this application page.
  //You can set the desired master page here. 
  //For this demo, I have set it to use the master page used by the SharePoint site this application page is called from
  this.MasterPageFile = SPContext.Current.Web.MasterUrl;
}
</script>

<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> 
<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %>
<%@ Import Namespace="Microsoft.SharePoint" %>

<asp:Content ID="Main" runat="server" contentplaceholderid="PlaceHolderMain">
    <!-- Whatever goes into the content area here -->
</asp:Content>

<asp:Content ID="PageTitle" runat="server" contentplaceholderid="PlaceHolderPageTitle" >
   Page title here
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" runat="server" contentplaceholderid="PlaceHolderPageTitleInTitleArea" >
   Title in title area here
</asp:Content> 

Thursday, September 23, 2010

How to implement your own custom web part zone in SharePoint?

Scenario:How to implement your own custom web part zone in SharePoint?

Explanation:
Have you ever wondered whether it is possible to implement your own custom web part zone that gives you full ability to control how the web parts in a web part zone are added to a page?

By default, MOSS 2007 as well as SharePoint 2010 render the web parts in a table.
As most of us know, HTML tables are meant to be used for displaying tabulated data but not for controlling layout of a page. Tables were created to provide structure to data.

Even though SharePoint 2010 moved away from the table approach to the div approach, few areas remain untransitioned, the "Web Part Zone" being one of them.

Its often an painespecially for developers/designers to get the exact output to match that of the markup provided by a 3rd party company / designer (Yes it is quite often the case that SharePoint developers need to output HTML that need to match the markup provided by the client) and some times requires lot of effort to tweak their CSS/HTML Markup and also to ensure that the page out put is XHTML complaint especially in MOSS 2007.

Typical output from an OOB SharePoint Web Part Zone looks like the below:


As you can see in the above screenshot, SharePoint renders web parts in a table.

If you use the custom web part zone that I have also contributed in Codeplex (credits go to Tim Nugiel from MSNGN), you will be able to control the way the web parts added to a web part zone are added to a page.


As you can see in the above screen shot, the custom web part zone allows you to control the way the web parts are rendered on the page. The above screenshot demonstrates a web part zone with a Content Editor Web Part and a Page Viewer Web Part.

In this sample code, I have just added web parts one after the other.
You might want to add each web part in a new panel, apply css to them / seperate them with a <hr> / whatever you want to do

 If you want to be able to add user controls to the page, you will need a text field/column in the SharePoint Page that will be used to define the user controls to be added to this page.

If there are multiple user controls that are required to be added to the page, seperate them with a ";"
To use this web part zone in a page layout, register the control by adding te below line to the page layout
<%@ Register TagPrefix="Custom" TagName="WebPartZone" Src="~/_controltemplates/CustomWebPartZone/CustomWebPartZone.ascx" %>
Add the control to the page layout at the desired location
<div id="divCustomWPZone">
    <Custom:WebPartZone runat="server" id="zoneCustom" DisplayTitle="Custom Zone" LoadWebPartZone="true"/>
</div>
If you want be to able to load user controls as well, just use the FieldName="Name of the page field that contains the user control(s) to add to the page"

Download Source Code