Thursday, November 24, 2011

The closed type does not have a corresponding "CustomerId" settable property

We got this issue when pulling data from a SharePoint list using REST Web services (used LINQ to SharePoint)

Earlier, the code worked fine and then we added a column in the SharePoint list (Column Name is "Customer"). Then, we started getting this error which contains the column name too. (CustomerId)

So, we updated the service reference (i.e http://sharepointsite/listname/_vti_bin/listdata.svc) and the error vanished.

Hope this helps :)

Tuesday, November 22, 2011

Programatically change Site and System Master Page in SharePoint 2010

Here is the code to change both Site and System Master Page in SharePoint 2010.

This code has been written in Event Receiver. When the feature is deactivated, automatically, v4.master is applied

 public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite oSite = (SPSite)properties.Feature.Parent;

            using (SPWeb oWeb = oSite.OpenWeb())
            {
                oWeb.MasterUrl = oWeb.ServerRelativeUrl + "/_catalogs/masterpage/CustomMaster.master";
                oWeb.CustomMasterUrl = oWeb.ServerRelativeUrl + "/_catalogs/masterpage/CustomMaster.master";
                oWeb.Update();
            }
        }


        // Uncomment the method below to handle the event raised before a feature is deactivated.

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite oSite = (SPSite)properties.Feature.Parent;

            using (SPWeb oWeb = oSite.OpenWeb())
            {
                oWeb.MasterUrl = oWeb.ServerRelativeUrl + "/_catalogs/masterpage/v4.master";
                oWeb.CustomMasterUrl = oWeb.ServerRelativeUrl + "/_catalogs/masterpage/v4.master";
                oWeb.Update();
            }
        }


Here, oWeb.MasterUrl refers to System Master Page and oWeb.CustomMasterUrl refers to Site Master Page.

Cheers !

Friday, November 11, 2011

The operation that you are attempting to perform cannot be completed successfully. No content databases in the web application were available to store your site collection.

We got this issue when trying to restore a site collection backup file in a web application.

The operation that you are attempting to perform cannot be completed successfully. No content databases in the web application were available to store your site collection. The existing content databases may have reached the maximum number of site collections, or be set to read-only, or be offline, or may already contain a copy of this site collection.

The reason for this error is that we have restored the backup file already in a different site collection in same web application. We got this error when trying to restore the same backup file in different site collection in same web application.

SharePoint 2010 by default accepts a backup file to be restored only once for a content database. Hence, whenever we are trying to restore the backup file to different site collection in same content database, we got this error.

The Resolution for this issue is to restore the backup file in different web application. This makes sure that the backup file is restored in a new content database. Cheers !