Raghu's SharePoint Corner: September 2008

My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://www.sharepointcolumn.com
and update your bookmarks.

September 23, 2008

How to create wsp (solution package) using WSPBuilder.exe (WSP Builder Project Template)

The easiest way of create solution package (WSP) is by using WSPBuilder. You can download the WSPBuilder.exe from the link provided below.

Download WSPBuilder.exe

Step 1: Install the wsp builder extensions and create a new project using WSP Builder Project Template


Step 2: The project structure will be as show below

Step 3: Add a feature to the project, Click Project->Add New Item->Select FeatureWithReceiver and click Add, in a similar way add event handler, The strucutre will be as shown below.
Step 4: Perform the coding as requirement and build the project. Inorder to create a wsp file Click Tools->WSP Builder -> Build WSP. A wsp package will be created, the project strucutre under widows explore will show a wsp file as shown below


Step 5: You can deploy solution directly from the tools menu or you can create a deployment folder Called Deployment on desktop,
copy all the required files to this folder. You can deploy using stsadm commands.
a. To add solution use stsadm.exe –o addsolution –filename “FileLocation”
b. To deploy solution use stsadm.exe –o deploysolution –name test.wsp –immediate –allowgacdeployment -force

September 22, 2008

Customization of application.master and default.master

Recently i had been into scenario where i have to change the default top navigation menu provided by MOSS OOB to a customized menu. Typically the navigation menu has site tabs.

I create the user control Menu and started to Integrate with the master page of the site.

I followed the following steps to add a user control to default.master

a.       Register the user control

b.       Import the namespace of the usercontrol

c.      Register the dll of the usercontrol

d.      Commented out the sharepoint:aspmenu  contro with id =”TopNavigationMenu”

e.      Add my user control in the place of the above commented control

f.      Added the dll to the gac

g.      Added safe control entries to the web.config file fo the site.

 I was happy to see the change on my site with new menu control. But that was not my final task, when I clicked on the View All Site Content link on the site, I saw that the my customized menu control was not rendering over this page. Later I found out that all the list level page and site collection level pages had the OOB menu. After searching on net I found a article on MSDN which fixed my problem.

 http://support.microsoft.com/kb/944105


 There are 2 solutions for this problem, since my website was a site collection, I followed the second approach.

 I made the modification in the application. master in the same way as default. master. It worked well for me. Both the approach have certain limitations and disadvantages. If anyone has an alternate approach for this, feel free to leave a comment

September 15, 2008

Create list with lookup column assosciated with the same list or other list.

I had run into a scenario where I need to have a lookup column in the same list and many views which are based on the look up column, at first I thought this is simple to implement, but once I started implementing it, I realized that it’s not so simple. I googled on net to find an alternate for my solution, but the soultions didn’t work for me.

Before entering the implementation part I would like to disccuss about lookup column archintecutre in list. Lookup column has two important attribute lookup list and the lookup field.

Lookup List: Indicates to which list the lookup filed should refer.
Lookup Field: Which column or filed need to be refferd or showed from the list specified above.

As a regular methodology I started implementing the list using feature since it would be easy to maintain views, I created a list using feature, b ut the prob was the lookup comun was not showing up any data. Later I came to know that internally look up column uses list id to keep the track of which list it should reffer. So I googled to find out how we can update the list id of a lookup column. You cannot update the lookup column using OOB UI if you have created a list using feature or list template. I went through the following blogs

1. http://www.sharepoint-tips.com/2007/04/fixing-lookup-fields-in-list-definition.html

2. https://www2.blogger.com/comment.g?blogID=20371103&postID=4251369915225974613

Since the lookup column requires List ID, there was no point in creating list using feature because the list id will be known only when the list is created.

I thought of another alternate is to create a list using feature and than to delete and create lookup column again by programmatically, but by doing this all my views related to the lookup column failed and when I tried to create a new item in the list, all the column which were created were not visible in the newform.aspx.

Finally I came up with a solution, which has a nice amount of coding effort. The solution was to create a list, lookup column and views programmatically (using code).

Here’s the code to fix the solution of Lookup Column in the same list.
SPList list = web.Lists[listName];
list.Fields.AddLookup("ParentMenu", list.ID, false);
SPFieldLookup parentMenu = (SPFieldLookup)list.Fields.GetField("ParentMenu");
parentMenu.LookupField = "MenuName";
parentMenu.Update();
list.Update();

Here’s the code to fix the solution of Lookup Column in other list.
SPList list = web.Lists[listName];
SPList newlist = web.Lists[newlistName];
list.Fields.AddLookup("ParentMenu", newlist.ID, false);
SPFieldLookup parentMenu = (SPFieldLookup)list.Fields.GetField("ParentMenu");
parentMenu.LookupField = "ColumnInNewList";
parentMenu.Update();
list.Update();

This is a work around and a long approach, feel free to respond or comment if u have any other alternate or better solution.

How To Create List Programmatically using Custom List Template (OOB)

How To Create List Programmatically using Custom List Template (OOB)
There are many ways to create a list as follows
1. Creating list Using OOB UI.
2. Creating list Using List Templates
3. Creating list Using Features
4. Creating list programmatically or by a code behind approach
Programmatically a list can be created by writing a console application or by creating exe. The advantage of creating list programmatically will also help you tp retain lookup column in the same list or some other list. I will be discussing regarding lookup column in my next article
This article is written to create a list using out of the box (OOB) custom list template using a code behind approach.The snippet belows shows how to create a list.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("siteurl”))
{
SPWeb web = site.OpenWeb();

web.AllowUnsafeUpdates = true;
Console.WriteLine("Creating Menu List..");

Guid listGuid = web.Lists.Add("ListName”, "Menu Contents For Intranet", SPListTemplateType.GenericList);
}
});
Console.WriteLine("List Created...");

The SPListTemplateType has all the OOB cusotm list template such has Announcements, Tasks, Comments etc. The GenericList is a custom list template which I have used in my code

How To Create List Programmatically using Custom List Template (OOB)

How To Create List Programmatically using Custom List Template (OOB)

There are many ways to create a list as follows
1. Creating list Using OOB UI.
2. Creating list Using List Templates
3. Creating list Using Features
4. Creating list programmatically or by a code behind approach

Programmatically a list can be created by writing a console application or by creating exe. The advantage of creating list programmatically will also help you tp retain lookup column in the same list or some other list. I will be discussing regarding lookup column in my next article
This article is written to create a list using out of the box (OOB) custom list template using a code behind approach.The snippet belows shows how to create a list.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("siteurl”))
{
SPWeb web = site.OpenWeb();

web.AllowUnsafeUpdates = true;
Console.WriteLine("Creating Menu List..");
Guid listGuid = web.Lists.Add("ListName”, "Menu Contents For Intranet", SPListTemplateType.GenericList);
}
});
Console.WriteLine("List Created...");

The SPListTemplateType has all the OOB cusotm list template such has Announcements, Tasks, Comments etc. The GenericList is a custom list template which I have used in my code

September 9, 2008

Best Practices and Resources For Custom Coding, Perfomance and Capacity Planning

Best Practices and Resources For Custom Coding, Perfomance and Capacity Planning

Perfomance of a MOSS site is the most important factor for a MOSS site. Its not so easy to write custom application using Sharepoint Object MOdel.
Recently Microsoft has Added technical articels as follows

Performance and Capacity Planning Resource Center for SharePoint Server 2007

This page contains resources to help you with performance and capacity planning for your SharePoint Server deployment—map your solution design to a farm size and set of hardware that supports your business goals.

http://technet.microsoft.com/en-us/office/sharepointserver/bb736741.aspx

Best Practices Resource Center for SharePoint Server 2007
To avoid common pitfalls and keep your Office SharePoint Server 2007 environment available and performing well, follow these best practices based on real-world experience from Microsoft Consulting Services and the product team.

http://technet.microsoft.com/en-us/office/sharepointserver/bb736746.aspx

Best Practices: Common Coding Issues When Using the SharePoint Object Model

http://msdn.microsoft.com/en-us/library/bb687949.aspx

September 8, 2008

MCTS: Microsoft Office SharePoint Server 2007 Configuration Study Guide: Exam 70-630

Hi Friends,

People who are interested in doing certification in Microsoft Office Sharepoint Server 2007 Configuration and seeking a  book for preperation of exam, can download the book from the follow below link


I searched a lot to get a book of 70-630 and finally ended up by finding this book.. 
Hope this would help many to prepare for the exam 
ALL THE BEST

September 5, 2008

Google Chrome 0xc0000005 Error

Google is unveiling its own New Browser christened as “Google Chrome” – This is gonna be a interesting fight now!! 
You can download the google chrome from the google web site
Here goes the link http://www.google.com/chrome

As always there is a Google touch in this browser as well.

In my opinion, The Architecture of Chrome is built upon an entirely different approach than the browsers we have in the market

 

-          looks like they have designed the browser with Process Isolation instead of multi-threading == STABILITY + SECURITY

-          And they are using WebKit for Rendering UI (used by Android)  == SPEED

-          V8 Core Engine == AMAZING JAVASCRIPT PERFORMANCE + BETTER INTERACTIVE WEB APPS

-          Omnibox == MORE USABILITY

-          SandBoxing per Process == REMOVAL OF PROCESS BOUNDARY BUT WITH SECURED RIGHTS [MALWARE CAN COMPUTE BUT CANNOT TOUCH COMPUTER RESOURCES]

-          Integration with Google Gears == EXTENSIBILITY

 

Seems to have a pretty solid foundation w.r.t Design and Architecture… 

I faced few problems after the installation of google chrome, Got a pop up message saying "Failed to Initialize the application properly", was totally annoyed after seeing this message. This was my first installation of google chrom on my laptop. Later consulted with my colleagues many of them had the same problem, and this was due to Symantec End Point Protection i guess.. Following was the tweak performed to get it working

 

Use the following:

 

-------

1.       Right-click the shortcut for “Google Chrome” on your desktop and goto “Properties”.

2.       In the target field, append “--no-sandbox” and Save.

-------

And if the above doesn’t work – then try:

-------

1.       Back up the registry on an affected system.

2.       Open the registry on the Agent system by entering regedit from a run prompt.

3.       Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services \SysPlant.

4.       Open the Start DWORD.

5.       Change the value to 4 to disable the drivers.

6.       Reboot the system to commit the changes. It started working fine after restarting the system. I followed the 2 nd step. Enjoying surfing Using Google Chrome