Monday, October 24, 2011

How to do SharePoint 2010 Content Deployment

There are many articles in the web by describing Content Deployment in SharePoint 2010. But most of the time (In my case it do not work fine always in first time :-( )  it is not working property and giving plenty of errors which direct us to restoring the backup rather than trying Content Deployment in the SharePoint Server.

Here I'm going to my experiences and how I'm resolving those errors and little bit of background about the  SharePoint Content Deployment. Luckily i have manage to successfully proceed with the SharePoint Content Deployment most of the time.

What is SharePoint Content Deployment 

Content deploy can be use to export (deploy) content from one site collection to another site collection. content deployment is taking care of following contents in the source site collection.

  • Web pages – Deploy corresponding images styles , master pages and etc.
  • libraries
  • lists
  • resources

Content Deployment do not deploy

  • programs
  • assemblies
  • features
  • configuration information(Web.config)

Most of the time Content Deployment fails due to features. in the later i will explain how to over come these issues.

How to Configure SharePoint 2010 Content Deployment

We will use following scenario for the deployment

image

First you need to create a site collection in the production server (Our One is production/sites/ALR) which you are going to use in the content deployment.

When you are creating I'm always using site template as Select Template Later in the Custom Tab.You can use the blank template also but I'm recommending this one  because this one worked for me  all the times.

image

After that you need to configure content deployment

For than go to Central Administrator –> General Application Settings–> Configure Content Deployment in the Production Server

image

go to this and 

  • allow Accept incoming content deployment jobs in Accept Content Deployment Jobs section.

 image

  • select Do not require encryption  in connection security.(If you want you can use https also. but for the moment select the other one. )

image

Then Go to Development Server and proceed following steps to configure deployment path and job.

First we need to Configure Deployment Job. For that Go to Central Administrator of the development machine and then General Application Settings and  then Configure content deployment paths and jobs.

image

then select New Job to create new content deployment job.

Then Specify Title and Description (Optional) and for the source application select Source Web Application as Development and Source Site site collection  as  /sites/ALR ( this is as per scenario you can choose your one)

then you need to give production server Central Admin URL with the Port to Destination Central Administration Web Application. here i found that some times we need to give the with IP addresses. but most of the time URL will work.

image

Then we need to provide authentication information. here most users are failing in this point (I were also). because what ever the selection we made we have to provide user name and password. Earlier i thought if we select windows authentication it does not need but it is not. Following shows sample values for  Authentication Information

image

after that select the destination Web Application and Site collection in Destination web application and site collection section.

image

For the moment leave Deploy User Names selected and Security Information All.

The SharePoint Automatically Create a Quick Deployment Job for you.

image  

For the moment leave this and create a Deployment Job by right clicking the Deployment Configuration.

image

Here you can schedule the content deployment but for the movement select following options but of cause you can change them as you want later.

SQL Snapshots --> Do not use SQL Snapshot
Scope --> Entire Site Collection

the clink and finish the job creation. then you will see following kind of a menu.

image

Now the hard part comes. In the Menu Click Run Now or Test Job. (I’m Recommending Test Job before actually run the Job. Because some times Run Now deploy content partially and failed thus better to Test the Job before it is actually run. ) Then Most of the Time you will get Test Failed. If Not you are very lucky, thus you can proceed with the Run Now. But if you get Test Failed (sure you are :-) ) Following are the workaround you can fixed those errors.

Following are the most common errors you are getting..

Could not find Feature someFeature.

This error coming because this feature is not in the Production Server. Thus Install the Feature to the production server and run the Test Job again, then it will say another feature is missing thus keep on adding or removing unnecessary features in the development machine until it get succeed. You can find more feature details by using  power shell commands (click here).  

Could not find Feature FT-01-bbb35132-7695-139b-2e18-27444285e766.

These features are InfoPath Form Template Features. Thus get the relevant Form template and upload it to the production server.  The run the Test Job and see the progress.

If every thing finds most of the time you are getting these kind of errors.

  • An unexpected error has occurred
  • A list, survey, discussion board, or document library with the specified title already exists in this Web site. Please choose another title.
  • Unable to import the folder _catalogs/fpdatasources. There is already an object with the Id d029169b-1f86-4275-bb99-dd78a48f7952 in the database from another site collection.

These errors are coming because content database is having these objects and those are orphan in the site collection. thus you can repair the content database to delete these orphan objects in the particular site collection. 

thus you can use following power shell command to get rid of these errors (click here).

Repair SharePoint Database

sometimes you may encountered with problems such as restoring failures and  content deployment failures thus it is better to repair the database and see where is there any orphan objects in the site collection.

For that go to SharePoint Management Shell as an administrator,

use following command

stsadm -o databaserepair -url <url name> -databasename <database name>

Example,

image

here no Orphaned Objects found if they are listed run the command with deletecorruption option.

stsadm -o databaserepair -url <url name> -databasename <database name> -deletecorruption

image

Tuesday, October 18, 2011

Power Shell Command for get SharePoint Feature (SP Feature) By ID

Use following power shell command to  search and get the SharePoint Feature.

Get-SPFeature -Identity ID

image

SharePoint Solution deployment not working and Falling in the front end after installing the SP1 (SharePoint Service Pack 1)

This issue is also generate the following event log.

Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance

Reason: Requested registry access is not allowed.

Technical Support Details:
System.Security.SecurityException: Requested registry access is not allowed.
   at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
   at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)

these might be other reason also like not having correct permission to the application pool running user. But in my case i solved it by running the SharePoint Product Configuration Wizard.

 image

Thursday, October 13, 2011

Presentation - MVC 3 @ University of Moratuwa

@ University Of Moratuwa 20 Oct 2011 10.30AM – 11.30AM
I have conducted this presentation  for IT students in Moratuwa University. The entire workshop is organized by Student Champs with great guidance of Wela.
I hope presentation went well and few questions are asked from student also. The presentation gave an introduction and guidance to Microsoft MVC 3 application development.  

Wednesday, October 12, 2011

Switch SharePoint Pages to Edit Mode

Type following JavaScript in the Address bar in the browser.
javascript:MSOLayout_ToggleLayoutMode();

Thursday, October 6, 2011

Generic Type Convert in C#

Cannot implicitly convert type 'object' to 'T'. An explicit conversion exists (are you missing a cast?) 

Following code can be use to convert your object to generic value.
T ret = (T)Convert.ChangeType(yourobject,typeof(T));

SharePoint 2010 List Template Ids

 

ID

List

ID

List

1200 Administrator tasks list 202 Meeting Attendees list
104 Announcements list 204 Meeting Decisions list
303 Blog Categories list 207 Meeting Objectives list
302 Blog Comments list 200 Meeting Series list
301 Blog Posts list 210 Meeting text box
105 Contacts list 211 Meeting Things To Bring list
120 Custom grid for a list 212 Meeting Workspace Pages list
118 Custom Workflow Process 117 No-Code Workflows
130 Data Connection library 2002 Personal document library
110 Data sources 109 Picture library
108 Discussion board 300 Portal Sites list
101 Document library 2003 Private document library
106 Events list 111 Site template gallery
150 Gantt Tasks list 102 Survey
100 Generic list / Custom List 107 Tasks list
1100 Issue tracking 112 User Information list
103 Links list 113 Web Part gallery
114 List template gallery 119 Wiki Page library
116 Master pages gallery 140 Workflow History
201 Meeting Agenda list 115 XML Form library

Wednesday, October 5, 2011

My SQL LIMIT Clause gives problems with Stored Procedure

I found the following workout.

CREATE PROCEDURE GET_SOMETHING ( IN paraFrom INT , IN paraPage INT )

BEGIN
    SET @SQL = CONCAT("SELECT * FROM customers LIMIT ",paraFrom" , ",paraPage ) ;
    PREPARE stmt FROM @sql; execute stmt;
END

Could not load file or assembly 'Microsoft.SharePoint.Sandbox' or one of its dependencies ..

Go to the bin folder and remove the DLL and debug. It should work. It worked for me.

Tuesday, October 4, 2011

Form resubmit on Refresh

I had issue with resubmitting the form  when user refresh the form. i had to disable this accidental behavior in the MVC3. Yes of cause we can redirect to another action to prevent this behavior. but in my case i do not want to do that. there fore i used following JavaScript to disable browser refresh and back button.

<script>
window.history.forward(1);
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler() {
switch (event.keyCode) {

case 116: // 'F5'
event.returnValue = false;
event.keyCode = 0;
window.status = "F5 disabled";
break;
}
}
</script>

Monday, October 3, 2011

InfoPath Repeating Rows Selection Issue/Problem

I had a problem with selecting InfoPath repeating rows for applying a condition. Therefore for i used following mechanism to correctly select the current row.  Here is my scenario,

image

I’m writing a formula for fld_CorpStatus by accessing field fld_corpOff. but i should access the same row data in the run time. there for i used following xpath expression to access the fld_corpOff.

current()/../fld_corpOff

Explanation :- we are getting the current (fld_CorpStatus)  and then go to it’s parent (CorpOfficeGroup) the access the fld_corpOff