Online Training On SharePoint
                      

Saturday 28 March 2009

Creating Site Collection in a Specific Content DB in SharePoint

I had a scenario where we had multiple content databases associated to a Web Application and we want to specify a particular Content DB in which SharePoint should create new Site collection. I tried to understand how SharePoint selects a content DB in which new site collection needs to be created when we create a new site collection from Central DB.

It depend on two factor:

1. Database Status: If the content database is in active state then only new site collection can be created into that. If the content database is in Offline mode SharePoint will not create any new site collection into this Content DB. Every Web application needs to have at least one Active Content DB. This was not helpful as I did not want to take the DB offline.

2. Difference between the maximum number of Site and Current number of sites:
If there are multiple content DB associated to Web Application which are in active state SharePoint decides the content DB based on the Difference between the maximum number of Site and Current number of sites. It creates the site in the Content DB where this difference is maximum.

We can control the maximum number of site collection which can be created in a content DB by changing the number in "Maximum number of sites that can be created in this Database" field.




now I added three content databases associated to a web application and all of them are in ready status. I have changed the maximum number of sites in each of them. Now when I create a new site collection it will go into the second content DB as this has 5 as the difference between Maximum number of site collection and current site collection. The other DB's has this difference as 3 and 4.:


Now after creating this site collection this difference is same for the second and third content db. Now in this case SharePoint checks the maximum number of site collection parameter in each associated content db .


The next site collection will be created in the Content DB where this number is highest.So the next site again will be created in the second content DB.



Now if we create one more site collection it will go into the third DB as this has the difference of 4 while the other two has the difference of 3.



So with this logic I was able to control this behavior and was able to specify the content DB in which SharePoint will be creating new site collections.

See also Creating Site Collection in a new Content DB

Thursday 26 March 2009

Consuming SharePoint Data from JavaScript

Found very interesting video by Kirk on to consume the data available in SharePoint list from JavaScript. The video shows how easily Solutions can be developed using Visual Studio Extensions for Windows SharePoint Services 1.3 (VseWSS 1.3). The solutions can be developed and deployed with a click of button through Visual Studio 2008.

Watch the video at Channel 9

Monday 23 March 2009

New Themes For Office Share Point Server 2007

Microsoft has released 10 new themes for SharePoint 2007. I installed the themes and used them and they are really cool.

You can download these themes from Microsoft Site

But It would be easier to use the Solution provided by Daniel at his blog to install the themes. This will deploy the themes as feature and they will be available for the selection in the site.



I have created one blank site and applied each theme and looks really great. Here is the screen shot of each theme:

1. Construction



2. Contoso



3. Corporate



4. Event



5. Owner Approver



6. Procurement



7. Publishing



8. Sporting



9. Startup



10. Team Site



Thursday 19 March 2009

Tabs not getting highlighted in Top Link Bar in Sharepoint Site

Recently I had a strange issue. In our SharePoint site the tabs in the top link bar were not getting highlighted when users were navigating to those tabs. The issue was solved after I edited the URL associated with tab from Absolute to Relative URL.

Here are the details of the issue and the solution:

1. Created a tab to appear on Top Link Bar from:

SiteSettings --> Look and Feel --> Top Link Bar



2. created the link with absolute URL like http://server:port/site/../pagename.aspx



3. Navigate to the tab from top link bar. See the tab is not highlighted:



4. Edited the URL from Absolute URL to Relative URL. Removed the server name.



5. Navigate to the tab from top link bar. Now the tab is highlighted:



Friday 13 March 2009

Creating Web App using an existing IIS Web Site

We can create a SharePoint Web Application by using an existing IIS web site.

The steps for doing this are:
1. Create a IIS Web Site
2. Go to Central Admin and select Create or Extend Web Application
3. Select " and it will show all the web sites in IIS where SharePoint is not associated.
4. Select the IIS web site and SharePoint will be associated with this web Site and this web site and it will become web application in SharePoint terminology.

But what I am really interested to tell what difference comes when we associate the SharePoint to a normal IIS web site or remove SharePoint from an IIS Web Site.

When we have SharePoint Web App there are some special Sub Virtual Directories which are part of it. The directories are:

1. _vti_bin mapped to $localdrive$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\isapi
2. _layouts mapped to $localdrive$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\template\layouts
3. _wpresources mapped to $localdrive$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\wpresources
4._controltemplates mapped to $localdrive$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\template\controltemplates

so all of these directories are going to SharePoint. So if we see in IIS it looks like:



Now if we go to Central Administration and from Application Management select "Remove SharePoint from IIS Web site" option we will be shown all the web app. If we select this web app and continue the operation it will delete only these sub virtual sites. so lets see how it looks in IIS:



So when we create a Web application based on a IIS site or remove SharePoint from Web Application these are the virtual directories which gets affected.

Tuesday 3 March 2009

Diagnosing Performance Issues on SharePoint with SPDiag

Microsoft has recently released a utility to diagnose and trouble shoot the performance related issues in SharePoint.

I used this utility (Download here ) and I found it very useful. When we create a project in it, it shows a ton of useful information which is quite handy for debugging the performance issues in the Farm. Their are two tabs in the UI one is Snapshot and other one is Trends. Snapshot shows more of the Static data while the Trends show the real time data on which debugging can be done.

In Snapshot we have have the information like:

Servers & Hardware:Shows all the servers which we have in the Farm. It shows the information like H/W information, Service running on each server, the build of SharePoint, the databases in the DB and status of each database etc. See the screen shot for the other information that we have:



Farm Logical Information:This is the second set of information which is more related to the what we have created in our Farm. It show all the different Web Applications we have, the content DB's, Solution deployed to the farm, Timer Jobs and their Status and the Content Deployment Path. One of the coolest feature is to display all the large list (having more than 3000 items).



Although all this information can be retrieved from the various sources but it really takes lot of time to consolidate this info. Here we can see all this info in a nice way and which can be updated real time if we are working on a online project.

The other feature is working in offline mode. So this helps me to work on this data on different machine. We can export the data through the Data tab which will create a snapshot in XML which can be viewed through this tool in offline mode.

The next thing is the Trends tab. I can decide for how much time we want to analyze the logs here. the next cool thing is select the servers and the web application in which we want to see the trends. I can select all the servers or one and the web applications (I have only one servers in the farm so showing only one).



We can select the Logs (IIS, ULS or Events Logs) from which we want to analyze the data. We can use these logs in combination as well. There are option to remove the data based on conditions.



We have the flexibility to select the performance counters available in different servers on which we want to do the monitoring and these counters will be added in the tool.



Based on these performance counters the data will be shown.

I am still experimenting with this and will keep updating this post.

Hiding/Displaying Content Type with SharePoint Object Model

I had a document library with which multiple content types are associated. When a user click the New button in the document library, I need to show or hide these content types based on the number of documents associated with a particular content type.When a specified number of documents are uploaded for a specific content type user should not be able to see this content type under the new button and when some documents associated to this content type, are deleted the content type should start appearing under the New menu item.

We can achieve this with the help of SharePoint Object Model. First we will find the number of documents for any specific content type in the document library and then in ItemUpdated event and ItemDeleted Events for the document library we can have the code to hide/display the Content Type:

To calculate the number of items related to a specific Content Type in a document library we can use following Code (cant put the code so putting it in sky drive):

private int FindNumberOfItems(SPList list)
{
SPQuery qry = new SPQuery();
qry.Query = "<Where><Eq><FieldRef Name='ContentType' /><Value Type='Text'>ContentTypeName</Value></Eq></Where>";
return list.GetItems(qry).GetDataTable().rows.count;
}

Download the code from:


So lets say X is the Number of Docs associated to a particular content type returned by the above code and now we want to hide the content Type when this number reaches 5 then the code required to be used is:

Code in the ItemUpdated Event:
If (X>=5)
properties.List.ContentTypes["NameOfContentType"].Hidden = true;
//This will make the Content Type not visible under “New” button in the toolbar
properties.List.ContentTypes["NameOfContentType"].Update();

Now same way we can start displaying this content type once the number of docs reaches below the specified limit. We need to call the code in the ItemDeleted Event.

Code in the ItemDeleted Event:
If (X<5) properties.List.ContentTypes["NameOfContentType"].Hidden = false; //This will make the Content Type visible under “New” button in the toolbar
properties.List.ContentTypes["NameOfContentType"].Update();

You may be interested to see
Introduction to Content Types

Related Posts with Thumbnails