Thursday, October 31, 2013

Lookup Field : Invalid data has been used to update the list item. The field you are trying to update may be read only when using Copy.asmx

Hi All,

We are using Copy.asmx in SharePoint to upload files including metadata information. While doing so, we got error for People Picker field as shown below:

Lookup Field : Invalid data has been used to update the list item. The field you are trying to update may be read only.

Resolution:

1. We need to set FieldType for FieldInformation object to User as shown below

2.  Add "-1;#" before User ID


Once this is done, the error disappeared and user id is properly copied to People and Groups field. Hope this helps some one. Cheers!!!


Folder-Level Permissions in SharePoint List

Background:
We often get requests to limit list items to a section of people like HR, IT, PMO, etc. HR should see fewer items that other groups should not and vice versa. The solution for this problem appears straight forward (by breaking permissions of items and assigning them to corresponding SPGroups). However, this approach leads to serious performance issues for a large number of items and can bring entire SPFarm down!

Why?
The recommended number of unique security scopes for a SPList is 5000. When the number of unique security scopes for a list exceeds the value of the list view threshold (set by default at 5,000 list items), additional SQL Server round trips take place when the list is viewed, and this can adversely affect list view performance.

Resolution
Possible workaround for this problem is to have folder level security in SPList. For the above problem statement, we will be having folders for HR, IT, PMO in SPList and HR folder will be accessed only by HR and Admin SPGroups (same approach for other folders as well)
With this change, all items under HR folder will inherit permissions from HR folder instead of having separate permissions. Below is the comparison between item level permissions and folder level permissions

List Item Count: 2000

Scope
Item count
HR
500
IT
600
PMO
900

Without using Folders –We would be having more than 2000 unique security scopes
With using Folder – We would be having 4 unique security scopes (Permissions for List itself and Permissions for 3 folders)
 

Partial Page Exclusion in SharePoint Search

Background:

Out of the box search results in SharePoint shows unnecessary data such as navigation, left nav, footer, right nav etc., that may not be useful to end user. Fortunately, it’s easy to exclude those items from appearing in search results by using a technique called “Partial Page Exclusion”.

How to use:

Just include a class called “noindex” for the items that needs to be excluded from search results. This tells the crawler to ignore those items. Here is a sample example in which crawler is forced to crawl only content present in body class. All other items are ignored.

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div class="wrapper">
<div class="header noindex">
// Header Data
</div>
<div class="topnav noindex">
// Navigation
</div>
<div class="body">
// Header Data
</div>
<div class="footer noindex">
// Footer Data
</div>
</div>
</body>

</html>

Wednesday, September 25, 2013

Error Publishing Content Type: No valid proxy can be found to do this operation

Hi All,

Below is the error we faced when trying to publish a content type from content type hub:

"No valid proxy can be found to do this operation"

















Resolution:

Make sure that on content type hub (source), Content Type Syndication Hub site collection feature is activated.










Thanks :)

Tuesday, August 20, 2013

SharePoint 2013 IFrame: This HTML cannot be inserted because this type of content is not allowed.

Hi All,

We got below error when trying to embed a IFrame in SharePoint 2013 Page (Edit Page > Embed Code)

IFrame code:

<iframe src="http://www.w3schools.com" width="600" height="400"></iframe>

and the error:

















Resolution:

Go to Site Settings > Site Collection Administration > HTML Field Security



























In "Allow iframes from this domain" section, add http://www.w3schools.com  and click OK as shown below:













Once this is done, the site is displayed properly in IFrame as shown below:























Hope this helps someone out there :)

Tuesday, February 12, 2013

Class not registered exception - SharePoint 2013

Hi All,

We got below error when trying to use SPSecurity.RunWithElevatedPrivileges in console application

Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).












The code is shown below:

using Microsoft.SharePoint;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SampleComnsoleApp
{
    class Program
    {
        
        static void Main(string[] args)
        {
            bool quiet = false;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                (new Program()).Run(quiet);
            });
        }
        private void Run(bool quiet)
        {

        }
    }
}

Resolution:

The console application is running under 32 bit processor. Just change it to 64 bit.
To do this:

  • Right click on Console Application
  • Select Properties 
  • Under Build Tab, change Platform Target to x64
  • Rerun the application and hopefully the error should go away now !

Sunday, February 10, 2013

Step by Step Procedure to Migrate sites from MOSS 2007 to SharePoint 2013

Hi,

To migrate sites from MOSS 2007 to SharePoint 2013, we need to first perform two tasks.

a. Migration from MOSS 2007 to SharePoint 2010
b. Migration from SharePoint 2010 to SharePoint 2013

Please follow the above links to perform migration and let me know in case of any issues.

Thanks !

Step by Step Procedure to Migrate sites from SharePoint 2010 to SharePoint 2013

Hi Again,

In this post, I will show how to migrate sites from SharePoint 2010 to SharePoint 2013.

Steps for Migrating SharePoint 2010 site to SharePoint 2013

1. Take backup of SharePoint 2010 Content database
2. Restore the SharePoint 2010 Content database in SQL Server 2012
 























3. Create a claims based web application. I want to use windows authentication. So I have selected “Enable Windows Authentication” checkbox while creating new web application.
















4. Note that classic authentication mode is removed by default in create web application page. You can create classic web application using PowerShell only.

5. We see that web application is created in Central Administration page










6. Open “SharePoint 2013 Management Shell” as Administrator
7. Detach the content database for the newly created web application using the below PowerShell command
    Dismount-SPContentDatabase -Identity "WSS_Content_SharePoint2013DB_4444"













8. Attach the Restored SP2010 Content database to the newly created SP2013 Web Application using PowerShell command

Mount-SPContentDatabase -Name WSS_Content_SharePoint2010ContentDatabase -DatabaseServer SHAREPOINT2013\SHAREPOINT -WebApplication http://sharepoint2013:4444/
















9. Depending on your project requirements, you may need to perform additional tasks
  • Update Web.config with
    • Connection strings to database (In case custom database is used)
    • Safe controls for Dll’s
  • Update Visual Studio code to VS 2010 (Applicable if 14 hive was used by your code. This needs to updated to 15 hive)
  • Update master page and page layouts to use dll’s of version 15.0.0.0. Note that we still have 14.0.0.0 version for Master page and Page layouts even after migration   
10. Browse the SharePoint 2013 site now and I got an access denied error as shown below












11. This is because the content database has got primary and secondary administrators of SharePoint 2010 site. This is not valid in my case since SharePoint 2013 is on another domain as shown below















12. Hence, I need to change the primary and secondary administrators to valid users as shown below and click OK to save changes

13. Welcome to your SharePoint 2013 Site! :)















14. Note that we are still in SharePoint 2010 UI. We also got a message to experience SharePoint 15 features. Click Start now

15. We get an “Upgrade Site Collection” page. Click “Upgrade this site collection”
















16. We get a popup. Click “I am ready”. Note that in SharePoint 2010 Visual upgrade, even though the site has been updated to SharePoint 2010 UI, we can still revert back to SharePoint 2007 UI using PowerShell. This is not the case with SharePoint 2013. Once the site is converted to SharePoint 2013, this cannot be reverted back to SharePoint 2010. 















17. You can see the upgrade status in Site Upgrade Status page 
       (http://<SiteUrl>/_layouts/15/siteupgradestatus.aspx)
       
      Upgrade Screen 1















       Upgrade Screen 2















18. Once, the upgrade is completed, we get a Upgrade Successful message













19. And, finally, here is our SharePoint 2013 site! :)















20. Everything got migrated properly without any issues. Kudos to the Microsoft SharePoint team for doing such an excellent job. Cheers!

Step by Step Procedure to Migrate sites from MOSS 2007 to SharePoint 2010 -


Hi All,

In this post, I will first explain how to migrate sites from MOSS 2007 to SharePoint 2010. 

Steps for Migrating MOSS 2007 site to SharePoint 2010

1.    We will migrate a simple site in MOSS 2007 to SharePoint 2010. Here is the screenshot of the site in MOSS 2007
         


2.      Set the content database for this site to READ ONLY before taking backup. 
       To do this, open SSMS and select the content database


















3.       Right click on database and select properties
4.       Under Options tab, set the database state to be READ ONLY as shown below
       

















5.    Once this is done, click OK to save changes. The database will be grayed out indicating that it is in READ ONLY mode





















6.       Now, backup the database


















7.    Once the backup is done, restore this backup on SQL Server that is connected to SharePoint 2010 Farm. I have SQL Server 2008 R2 that is connected to SP 2010 farm.
8.    To restore the MOSS 2007 content database to SQL Server 2008 R2, open your SQL Server 2008 R2 in SSMS
9.      Right click on Databases and select Restore database
10.   Select “From Device” option under “Source for restore”. Then Select the backup file




















11.   Provide the name of database under “Destination for restore” => “To database”. FYI, I restored my MOSS 2007 content database to SQL Server 2008 R2 as “WSS_Content_MOSS2007ContentDatabase”

12.   Now, go to central administration page for SharePoint 2010 and create a new web application. Do not create any site collections for this web application as we will delete content database for this web application. The name of content database for this web application is “WSS_Content_TempWebApp_4444”.












13.  Delete the content database for newly created web application (http://saiabhilash:4444/) using PowerShell command
      
      Dismount-SPContentDatabase -Identity "WSS_Content_TempWebApp_4444"

14.  Now, attach the MOSS 2007 content database to this web application using PowerShell command

Mount-SPContentDatabase -Name WSS_Content_MOSS2007ContentDatabase -DatabaseServer SAIABHILASH\SHAREPOINT -WebApplication http://saiabhilash:4444/

15.  Once this done, verify that the MOSS 2007 content database is successfully attached to SharePoint 2010 web application (Manage Content databases page in Central Administration)










16.  Depending on your project requirements, you may need to perform additional tasks
a.       Update Web.config with
                                                   i.      Connection strings to database (In case custom database is used)
                                                 ii.      Safe controls for Dll’s
b.      Update Visual Studio code to VS 2010 (Applicable if 12 hive was used by your code. This needs to updated to 14 hive)
c.       Update master page and page layouts to use dll’s of version 14.0.0.0. Note that we still have 12.0.0.0 version for Master page and Page layouts even after migration

17. This is it. Once this is done, we see the migrated site in SharePoint 2010 as shown below J













18.  We still see that UI is still in 2007 format. Use Visual Upgrade to see the updated UI (Site Actions รจ Visual Upgrade)














19.   Select “Update the user interface” tab and click OK to see SharePoint 2010 UI.


























20.   Welcome to SharePoint 2010! J














In next post, i will show you how to migrate sites from SharePoint 2010 to SharePoint 2013. Cheers !

Friday, January 25, 2013

Packaging SharePoint 2013 Solutions in Visual Studio 2012

Hi All,

To generate wsp file in Visual Studio 2012, follow the below steps.

1. Right click on SharePoint 2013 solution
2. Select Publish option





















3. Select Publish to File System and provide target location to store wsp location


















4. Once Publish is clicked, wsp file will be generated in specified location.

Hope this helps.

Friday, January 11, 2013

Making solutions for SharePoint 2010 in VS 2010 work in SharePoint 2013

Hi All,

We all know that in SharePoint 2013, the SharePoint Root was renamed to 15 hive. Microsoft has been doing this for every new SharePoint release. For instance, in MOSS 2007, it was called as 12 hive and in SharePoint 2010, its called as 14 hive.

Now, we have a Visual Studio project that was created for SharePoint 2010. When we try to deploy this solution on SharePoint 2013, all files targeted to sit in SharePoint Root was actually copied to 14 hive instead of copying in 15 hive.

The reason for this is in solution's manifest file, we have an attribute for <Solution> tag called as SharePointProductVersion which was set to 14.0. This is the reason for the files to be copied to 14 hive.









Now, to make the solution work for SharePoint 2013, we just need to change version from 14.0 to 15.0.

Hope this helps someone out there. Cheers!