11 Common Mistakes Made In Sharepoint

Introduction

SharePoint - the buzz word for web portal that is browser based and drives towards effective management of data with ease. Also termed as one of the effective collaborative tools helping offices of all sizes to share the information effectively and manage day-day office processes through elegant workflows.

This article outlines few of the common mistakes encountered when working with SharePoint and Sharepoint solutions.

CAML Queries Don't Apply The Filters

CAML syntax is widely used to query the Document Library and the workflow. CAML Stands for "Collaborative Application Markup Language" and is XML-based. The Microsoft SharePoint assembly provides the SPQuery object that helps you query using the SharePoint Object Model.

SPQuery myQuery = new SPQuery();
myQuery.Query = ""<Query>..<Where>...</Where></Query>";

The Query property of the SpQuery object does not need the <QUERY> tag in the Query. This causes the filters not to be applied. Remove the Query tags and the filters shall be applied with the Query.

Also, a good practice is to use the "ViewFields" property to retrieve only required fields from the Query. You can specify these using the ViewFields property of the Query Object. A sample snippet is as shown below:

oQuery.Query.ViewFields = "<FieldRef Name='Age' />";

Dreaded Error

First thing that strikes is the Unknown error in the SharePoint Page. This is known at times as the dreaded message. A lot of effective mechanisms to tackle this problem are provided on the web. Nevertheless, a quick mention of the easiest step would be worthless.

SharePoint does the job of hiding the exact error message from the .NET framework, thereby answering the concerns of security. However, the stack trace that is secured through the default behavior of the SharePoint is the vital need for the solution to such unknown errors.

For a developer to figure out the stack trace for an error, all the user has to do is to turn off the custom error in the web configuration file. In the Web configuration file of the site, look for the SafeMode tag. Under this tag look for the CallStack attribute. Set it to true to enable the Call Stack.

<SafeMode CallStack="true">

Additionally, look for the customErrors node and change the mode attribute value to Off

<customErrors mode="Off">

After changing these two values in the web configuration file, safe the web.config file and run your application. Ensure that you do these in your production environment only to figure out the actual error and then do not forget to toggle the values of the CallStack and the mode attributes of the SafeMode and the CustomErrors tags respectively. If you fail to do this, you might be compromising the security of the application.

These errors typically occur when you don't possess the right level of permissions to create sites OR add documents to a library.

Strange Errors After A Config Change

Strange errors can appear after a configuration change to the SharePoint application. This typically happens when you make changes to the "Alternate Access Mappings" or any other config changes. Timer jobs also fail to complete successfully at times.

Clear the SharePoint Configuration Cache in such cases.

SPLISTITEM Does Not Update The Object Properties

When we try to set values for SpListItem properties with the help of an Indexer, the values are not updated. The right way of doing this is to use the SpListItem object itself.

Instead of:

var list = web.List["theListName"]
list.Items[0]["field1name"] = "val1"
list.Items[0]["field2name"] = " val2"
list.Items[0].Update()

write, 
SPListItem myItem = web.List["theListName"].Items[0];
myItem ["field1name "] = " val1"
              myItem ["field2name "] = " val2"
              myItem.Update()

,

11 Common Mistakes Made In Sharepoint

Controls Are Not Visible In Custom Web Parts

Custom web parts needs to follow a thumb rule. One must override the Web part's base class method: The RenderWebPart, and Render the children to make the controls visible.

It would look like the following:

protected override void  RenderWebPart(HtmlTextWriter output)
{
     RenderChildren(output);
}

An Offset Of A Day In Dates

The Day Light Saving Time has a huge impact of the display of dates in SharePoint and elsewhere. An offset can be experienced in dates based on the TimeZone differences.

The trick to solve this issue is to change the TIMEZONE xml file. Search on the web for more info on how to change the TIMEZONE xml file.

This Microsoft's Knowledge base article has more info on this topic: http://support.microsoft.com/kb/933853/

How To Effectively Delete A File From The Document Library

The easiest way to effectively delete a file from the document library would be to set the Expiration for the Site Creation Policy. Additionally, you would have to set the Retention period. The last step would be to attach the workflow to the list.

Programmatically, one would use the SPQuery class to query for selected files/all files and send us a date/volume. Although one would use this method to have a greater control over the document library.

ACCESS DENIED Message When One Tries To SET QUOTA From An SPSite

This error is encountered when one tries to set the Quote for a site from code-behind. Set the Quote to a higher value and do not forget to turn the AllowUnsafeUpdates property of the Web to true. Needless to say, you would have to turn this off after setting the Quota.

Sample Code snippet shown below:

SPContext.Current.Web.AllowUnsafeUpdates = true;
SPContext.Current.Site.Quota = SPWebService.ContentService.QuotaTemplates["quota"];
SPContext.Current.Web.AllowUnsafeUpdates = false;

Your Client Does Not Support Opening This List With Windows Explorer.

When a folder is opened in the Document Library in the Explorer view, the folder does not open. Instead the above message is shown. This is explained in details in the Microsoft Knowledge base article # 923906 titled, "When you try to open a folder in a Windows SharePoint Services 3.0 document library in Explorer View, the folder does not open"

A Web Part Or Web Form Control On The Web Part Page Cannot Be Displayed.

The above said error occurs when we do not specify the Assembly information correctly in the configuration file. This typically includes incorrect name of the assembly, version, public key token or the TypeName.

TIPS

Configure Single Sign On In Sharepoint 2007

The Single Sign on systems are used to consolidate the multiple logins usage in a system. To prevent the usage of the multiple logins and configure Single Sign On in SharePoint server 2007, do the following.

  • Navigate to the Central Administration.
  • Choose Operations.
  • Select the Section titled, "Security Configuration" and choose "Manage Settings for Single Sign-On".
  • Choose Manage Server Settings under the window that appears
  • Specify the single sign-on Administrator account in the Account Name box.

Generate Emails From A Sharepoint List

Third party providers like the SharePoint Workflow Extensions from nSoftware allow you to generate the emails from the SharePoint list.

Conclusion

I hope you have found this article useful and that you can avoid some of these common Sharepoint programming mistakes.



About the Author

Srinath M S

I would love to leave a footprint in this flat world

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • A modern mobile IT strategy is no longer an option, it is an absolute business necessity. Today's most productive employees are not tied to a desk, an office, or a location. They are mobile. And your company's IT strategy has to be ready to support them with easy, reliable, 24/7 access to the business information they need, from anywhere in the world, across a broad range of communication devices. Here's how some of the nation's most progressive corporations are meeting the many needs of their mobile workers …

  • New IT trends to support worker mobility — such as VDI and BYOD — are quickly gaining interest and adoption. But just as with any new trend, there are concerns and pitfalls to avoid.  Download this paper to learn the most important considerations to keep in mind for your VDI project.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds