Thursday, March 1, 2012

SharePoint 2010 Data View Web Part - Unable to display this web part

This post covers yet another nightmare that I had faced while working on one of the "terrible" areas in SharePoint. Yes, the topic is on Data View Web Part. The reason why i call it "terrible" is not because its difficult to understand, but with DVWP one tends to run into problems which is difficult to solve OR the reason is unknown. The main reason for this is because, the error message which is shared is very generic.

I faced a similar problem sometime back and here it goes... Could be a limelight for few of them, facing the same issue.

Problem Description
The Data View Web Part inserted on a page displays an error message instead of displaying the actual content. The error message is

"Unable to display this web part. To troubleshoot the problem, open this web page in a Microsoft SharePoint Foundation-Compatible HTML editor such as Microsoft SharePoint Designer. If the problem persists, contact your Web Server Administrator. Correlation ID....."

We faced this issue after deploying the SharePoint Site from one location to another through Site Backup-Restore methodology AND the first time a NON-Site Collection Administrator logs in to the page where the web part is hosted. The very moment, when a site collection administrator logs in & logs off and then sign in again as the normal user, the error is no more there.

It wasn't just this. The error comes back again inconsistently. But every time, it gets resolved immediately after the swap of logins.


The log files were also not helping much. Below is a snapshot of what the log file message looked like.

"Error while executing web part: Microsoft.SharePoint.WebPartPages.WebPartPageUserException: Personalization has been disabled for this zone.     at Microsoft.SharePoint.WebPartPages.SPWebPartManager.ThrowIfCantModifyZone(String zoneID, Boolean throwIfLocked)     at Microsoft.SharePoint.WebPartPages.SPWebPartManager.ProcessZoneId(WebPart webPart, Boolean throwIfLocked)     at Microsoft.SharePoint.WebPartPages.SPWebPartManager.SaveChangesInternal(SPLayoutProperties layoutProperties, Boolean skipRightsCheck, Boolean skipSafeAgainstScriptCheck)     at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.get_CustomizedXsl()     at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.LoadXslCompiledTransform(WSSXmlUrlResolver someXmlResolver)     at Microsoft.SharePoint.WebPartPages.DataFormWe... 73266dea-1438-40f8-9996-3f57e13878e0
...bPart.GetXslCompiledTransform()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform) 73266dea-1438-40f8-9996-3f57e13878e0
Leaving Monitored Scope (DataBinding DataFormWebPart (Sales Communications)). Execution Time=1587.0504032229 73266dea-1438-40f8-9996-3f57e13878e0"

Here is a related link which explains the same problem, but solution is to remove and add the user to the security group OR to the site directly. http://social.technet.microsoft.com/forums/en-US/sharepointgeneral/thread/7bbe8087-bd12-4ace-9fa5-578f6fdb4217
We tried with the same and it did not help us.

Solution
This error occurs when the "AllowPersonalization" property of the Web Part Zone is set to false and a user with less privilege tries to access the zone. This leads to the WebPartPageUsageException. This could be overcome by just setting the AllowPersonalization property to true.

NOTE: Please respond if anyone has a different thought on the whole topic :)

Thanks for reading!!

Wednesday, January 25, 2012

Ribbon for READ Permission in SharePoint 2010 Publishing Page

While i was working in my previous project, this was one of the issues that i had faced for which i had spent a lot of time googling. I'm posting this information so that anyone else who gets into the same situation does not waste much time.

This is about the behavior of ribbon in SharePoint 2010 based on the permissions. 

The requirement what i had was to have the ribbon available for all the users. The ribbon was supposed to be  activated based on the context (For Ex: when clicked on any of the list items within a list view web part, the contextual ribbon must get displayed.) even for READ users.
However, the ribbon in publishing pages gets activated only for users with a minimum of “AddAndCustomizePages”. Which means that, the ribbon permission level needed to be downgraded from AddAndCustomizePages -> ViewListItems/ViewPages OR any READ level permission in order to be made available to all users. Though many sites mention ribbon as a default behavior for any user and customization is required to HIDE it from anonymous users. Whereas we see the opposite behavior in our case. This inbuilt behavior is because SharePoint reduces the page overhead for users with less privilege.

I also ran through couple of solutions offered from other sites as mentioned below but unfortunately none of them worked out.
@  Change the PermissionsLevel attribute to “ViewListItems” instead of “AddAndCustomizePages” for the <SharePoint:SPRibbon> in the master page.
@  Embed the div area displaying the ribbon (s4-ribbonrow) within <SharePoint:SPSecurityTrimmedControl>, set the appropriate permission level for this tag and for other set to display:none.

Below are the links which were referred:

Hence, the conclusion is - The ribbon in publishing pages gets activated only for users with a minimum of “AddAndCustomizePages”. This inbuilt behavior is because SharePoint reduces the page overhead for users with less privilege. Its better to think a different design approach if you are hanging on the same scenario.

Alternately, if someone has different thought on the same topic may respond to this post.