Friday, August 26, 2011

How To Download Folder from SharePoint Document Library or List

Scenario: SharePoint document library download folder

Generally SharePoint is used for Content & Document Management System. If it is more of Document Management System, users will upload and download files and documents quite often to/from document library or list.

Downloading a single document or file is straight forward, by clicking on the file. But there is no straight way to download folder from SharePoint document library. And downloading one by one file from a library is hectic if it has has more number of files (say 100s).

However a folder with all the files can be downloaded easily by following the below steps:
1. Go to the document library or list.
2. Open Explorer View of the respective document library.
3. Drag & Drop the folder from library to local drive.
                               OR
    Select the folder -> right click -> copy, then paste it on the local drive.

Tuesday, August 23, 2011

How To Install IIS7 on Windows7 and Windows Vista

I have faced issues in configuring/installing II7 on my machine (which has windows 7 installed) from Control Panel -> Program Files -> Turn Windows features on or off. It is always throwing an error message "one or more components are not installed".

To address this i found a nice(microsoft) tool Microsoft Web Platform Installer, which installs II7 in a single click.
And also it provides many other microsoft related features installation/configuration.


How To Repair SUSPECT Database

Sometimes we see a SharePoint error "Cannot connect to the configuration database". One of the reasons for this could be the Respective DataBase is set to SUSPECT mode.

Reasons for database SUSPECT state:
1. Database corruption.
2. Not enough space for the SQL Server to recover the database during startup.
3. Insufficient memory or disk space.
4. Unexpected SQL Server Shutdown, Power failure or a Hardware failure.

Follow the below steps to repair the SUSPECT database:
1. Identify all the databases which are in SUSPECT mode
USE master
GO
SELECT NAME,STATE_DESC FROM SYS.DATABASES 
WHERE STATE_DESC='SUSPECT'
GO
Note:Check the latest log for the database which is marked as suspect.
SQL Server -> Management -> SQL Server Logs

2. Get the database first into EMERGENCY mode to repair it
USE master
GO 
ALTER DATABASE "databasename" SET EMERGENCY
GO
Note: The EMERGENCY database is one way which means read-only.

3. Repair the Database in emergency mode
DBCC checkdb('databasename')
ALTER DATABASE "databasename" SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('databasename', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE "databasename" SET MULTI_USER

Thursday, August 11, 2011

SharePoint Feature Activation Dependency

Scinario:
While provisiong two dependent(one on the other) content/solutions through different features, it is that one of the features might need the resources of other while gettting activated. In this scinario the first feature should be activated before the second, to avoid the dependency issues.

Example:
Feature 1. Custom Content Type
Feature 2. Page with Custom Content Type (dependent on custom content type)

To make sure the same through feature provisioning instead manually, we have feature activation dependency attribute which can be specified in feature.xml file. Which doesn't allow to get activated unless until the dependency feature(s) is activated.




Note: Multiple dependencies can be specified for one feature.

SharePoint PageViewer WebPart Resize Issue

SharePoint OTB PageViewer works fine to display a static web page. But it has a Resizing issue when the source web page has some links which redirects to some other target pages (of more dimentions than source page) within the PageViewer webpart.

Issue/Scinario:
1. A custom search page of height 500x300 is added to pageviewer.
2. The results page with 2 results resize to 300x200.
Now say the result item link redirects to new web page of dimensions 600x500. As pageviewer doesn't support resizing the new page will be shown in 300x200 dimensions.

Solution:
A Content Editor WebPart instead PageViewer WebPart can be used with below iframe and source script to address the resize issue.

Limitations:
The content editor webpart height and width should be set to fixed values(for best page view).




Wednesday, August 10, 2011

SharePoint Copy Survey from One Server to Another

Migrating the survey list from one location(server) to another location(server) is very simple, if we go for list template. But this process doesn't work if the requirement demands for the existing responses along with survey details.

Though it copies all the survey details and responses details, the responded user(created by and modified by) and datetime (created and modified) details are replaced with current user (who is creating the survey with the template) and current datetime details.

To copy the survey as is (all questions and responses) i found a nice codeplex tool SharePoint Content Deployment Wizard. The post has the detailed documentation on what it can do and how can be used.

This also works with limitations:
The settings of the source Survey should be set as follows before copying.
Go to Survey list -> Survey Settings
1. Allow multiple responses (Yes)(Advanced Settings)
2. Edit access: Specify which responses users can edit
All responses (Yes)(Title, Description and Navigation)
After copying the survey, the settings can be again changed to earlier state.

It also helps in copying the following as well.
- site collections
- webs
- lists
- folders
- list items (including files)

Tuesday, August 9, 2011

SharePoint ListItem New, Edit and Display forms Dynamic URLs

Getting the SharePoint List Item form URLs(New, Edit ad Display) dynamically respect to the context instead of hard-coding.

SPListItem listItem = SPList.GetItemById(itemID);

// New form full url
string newFormFullUrl = string.Format("{0}{1}?ID={2}", listItem.Web.Url, listItem.ParentList.Forms[PAGETYPE.PAGE_NEWFORM].ServerRelativeUrl, listItem.ID);

// Edit form full url
string editFormFullUrl = string.Format("{0}{1}?ID={2}", listItem.Web.Url, listItem.ParentList.Forms[PAGETYPE.PAGE_EDITFORM].ServerRelativeUrl, listItem.ID);

// Display form full url
string displayFormFullUrl = string.Format("{0}{1}?ID={2}", listItem.Web.Url, listItem.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl, listItem.ID);

//Relative Url
string newFormRelativeUrl = string.Format("{0}?ID={1}", listItem.ParentList.Forms[PAGETYPE.PAGE_NEWFORM].ServerRelativeUrl, listItem.ID);