Wednesday, October 27, 2010

How to solve Microsoft.SharePoint.SPException: A file with the name xxx already exists. It was last modified by SHAREPOINT\system on xxx

In the workflow, if the workflow needs to update the column/field of the current workflow list item, i.e., workflowproperites.listitem, workflowproperties.listitem.update() will cause above exception. To solve this problem, the workflow needs to retrieve the listitem independently, as suggested by this blog by

My resolution is to add a simple property to my WF class. What it will do is ensure that I always load up the SPListItem every time I need it.

private SPListItem WorkflowItem
        SPDocumentLibrary library = (SPDocumentLibrary)WorkflowProperties.Web.Lists[WorkflowProperties.ListId];

        return library.GetItemById(WorkflowProperties.ItemId);

There are many suggestions about how to fix this problem, but this one did it for me.

Monday, October 25, 2010

Service Account Suggestions for SharePoint 2010 from Todd Klindt

Service Account Suggestions for SharePoint 2010

Friday, October 15, 2010

Start SharePoint Workflow from Web Services

Just some quick points:
  • I place the web application with the web services under the same application pool of SharePoint, also in the web services I use SPSecurity.RunWithElevatedPrivileges. Otherwise, you may run into the error message like the following: System.IO.FileNotFoundException thrown by the SPSite constructor.
  • Also I enabled web.AllowUnsafeUpdates so that to not run into security validation error.

Creating a Custom Web Service for SharePoint

Creating a Custom Web Service for SharePoint

Wednesday, October 6, 2010

Task failed because "sgen.exe" was not found: solution

When building an InfoPath solution with code behind, with web services references, you may run into above error message. The following link provides 2 solutions, but the first solution did not work for me, the second one did.

Friday, August 27, 2010

SharePoint 2007 Crawled Property Creation

Just an interesting observation.

In the SharePoint 2007 farm, if there are more than one list columns with the same name, for example, "Report Name", not in the same list, of course, SharePoint creates only one crawled property for all those columns with the exact same name, and the crawled property is named as "ows_Report_x0020_Name".

Here is how I did the test.
  1. Create a list named abc with a column "Report Name", fill in some dummy value
  2. Do an incremental index
  3. In SSP, there is a new crawled property named "ows_Report_x0020_Name" created
  4. Create another list named xyz with a column "Report Name", fill in some dummy value
  5. Do an incremental index
  6. In SSP, there is still only one crawled property named "ows_Report_x0020_Name", there is nothing else similiar to "ows_Report_x0020_Name" 

Tuesday, August 24, 2010

SharePoint 2010 Application Development Resources

Developing Applications for SharePoint 2010

SharePoint 2010 Walkthrough Guide

SharePoint 2010 Developer Training Kit


URL path length restrictions (SharePoint Server 2010)

URL path length restrictions (SharePoint Server 2010)

Guide on resolving url length problem from the article:

  • Upgrade all the end-user browsers to Internet Explorer 8, which has a longer URL length limit.

  • Use shorter names for sites, folders, and documents and control the depth of the site and folder structures to reduce the lengths of URLs.

  • If possible or allowed, use ASCII names for sites, folders, and documents. This will avoid situations where the URL will be lengthened by being encoded.

  • To reduce the risk that the SharePoint Server 2010 end-users will encounter problems because of URL length limitations, we recommend that you apply the following effective limits in the deployment:

    • 256 Unicode (UTF-16) Code units - the effective file path length limitation, including a domain/server name

    • 128 Unicode (UTF-16) Code units - the path component length limitation

Monday, August 9, 2010

What's New of SmartTools for SharePoint Time Display Bug and Fix

If you have not heard of SmartTools for SharePoint, then you need to check it out. It has several very useful SharePoint 2007 extensions to "make your life as a SharePoint user, developer or administrator a little bit easier!", to quote from the site.

However, the WhatsNew web part displays the modified date and time coloumns incorrectly, specifically, it converts the time from SharePoint to local time one time more than necessary. For example, it shows "6:56 AM" for a document last modified at "11:56 AM". The SharePoint regioinal setting is US Central Time. You can see the difference is 5 housrs, which is the difference between US Central Daylight Time and GMT.

The fix is very easy. In the source code which you can download from the site, comment line 406 and 411, and uncomment line 407 and 410. See correct code below.

                    if (modifiedDateTime.Date == DateTime.Today)
                        row["ModifiedDate"] = "Today";
                        //row["ModifiedDate"] = SPUtility.FormatDate(SPContext.Current.Web, modifiedDateTime.Date, SPDateFormat.DateOnly);
                        row["ModifiedDate"] = modifiedDateTime.Date.ToShortDateString();

                    row["ModifiedTime"] = modifiedDateTime.ToShortTimeString();
                    //row["ModifiedTime"] = SPUtility.FormatDate(SPContext.Current.Web, modifiedDateTime, SPDateFormat.TimeOnly) ;

SPUtility.FormatDate assumes the given time is UTC time and converts to local time based on regional settings (See what is good to know about SPUtility.FormatDate). When the code gets the modifiedDateTime, it is local time already. Another conversion to local time therefore is not necessary.

In SharePoint, Datetime value is stored as UTC time. When setting datetime, SharePoint converts the input to UTC and stores the UTC value; when displaying datetime, SharePoint converts the UTC time to local time.

According to this blog sharepoint web services and utc time fun and games from Andy Burns, there is some kind of problem with web services.

Friday, July 23, 2010

SPItemEventReceiver ItemAdded not firing

If you have configured ItemAdded event handler on a document library, and if you upload the same document multiple times, the first time ItemAdded event handler is fired. With the just uploaded document still in the library, subsequent uploading of the same document will not cause the ItemAdded event to fire.

I assume that SharePoint treats the subsequent uploading of the same document as an item being updated, not as being added, as in adding a new one.

Wednesday, July 14, 2010

FAST Query and FAST Content Search Service Applications in a SharePoint 2010 deployment Explained

After FAST for SharePoint 2010 (FAST4SP) is installed and configured, there are 2 search service applications associated with FAST4SP: FAST Query Search Service Application and FAST Content Search Service Application (Your search service application name could be different). It took me a while to realize the differences between those 2 service applications. The following blog entry helped me a lot learning those 2 service applications.

The two types of Search Service Applications (in a SharePoint 2010 deployment with FAST Search Server) - On The Search - Site Home - MSDN Blogs

In summary, FAST Query is used to service all search queries and crawl People content, i.e., User Profiles. So under the Search Administration page for FAST Query, there should be one and only one Content Source defined, with Start Addresses with only one entry, like sps3://hostname. Also search scopes should be defined under FAST Query service application. This blog entry demonstrates how to create a search scope in FAST Query from content source defined in FAST Content.

FAST Content is used to crawl all other content sources other than People. Out of the box under the Search Administration page of FAST Content, we should remove the entry of sps3:// from the content source's start addresses text box. Also note there is no search service application proxy for FAST Content.

Friday, July 2, 2010

Customizing My Sites in Microsoft SharePoint 2010 - Microsoft SharePoint Social Computing Team Blog - Site Home - MSDN Blogs

Customizing My Sites in Microsoft SharePoint 2010 - Microsoft SharePoint Social Computing Team Blog - Site Home - MSDN Blogs

It answers the following questions:

  • How do I change the top navigation on My Sites to include other links?
  • How do I brand My Sites?
  • How to add a customization to all existing personal sites?
  • How do I use personalization sites?
Must read before doing any customization with My Site.

    Add custom refiners to SharePoint 2010 Search Result

    In Expanding the Refiners

    By Todd Carter, he explains the basics of the refiner and how to add a new refiner based on file size to the search result page.

    Thursday, July 1, 2010

    Exporting SharePoint Document Library and Lists to Excel, including attachments

    Exporting SharePoint lists to Excel, including attachments

    One thing to note from the code provided by Bjørn Furuknap is that before creating the SPFolder object, we need to ensure the list item has attachment, if not, then creating SPFolder object causes exception. I used
    to check the exisence of attachment or not.

    Here is a codeplex project you can download for downloading SharePoint document library into a zip file.

    Chris O'Brien: Deploying master pages and page layouts as a feature

    Chris O'Brien: Deploying master pages and page layouts as a feature

    Tuesday, June 22, 2010

    Uploading files using the Client Object Model in SharePoint 2010

    In the article Uploading files using the Client OM in SharePoint 2010 by Tobias Zimmergren,

    he guides us through the process of uploading a document to any chosen document library in SharePoint 2010 through the Client Object Model, with sample project for download.

    Thanks for sharing this.

    Tuesday, June 15, 2010

    Adding Custom Action to SharePoint 2010 Central Administration

    The information on MSDN is not correct. The following blog

    Custom Action Definitions in SharePoint 2010

    By Arjen Bloemsma

    lists some custom actions, and their locations and group ids. 

    For example, the following custom action is placed on Central Administration ->System Settings ->Farm Management

            Title="the title here"
            Description="the description.">

    Note the aspx page is in the _admin directory, instead of the _layouts, since it is a page used in Central Administration.

    One take-away is if you have solutions which add custom actions to SharePoint 2007 Central Administration, then you need to make sure the custom actions show up at the right location, if showing up, under SharePoint 2010 Central Administration. As you probably know, MSFT has done a lot of re-organization in SharePoint 2010 Central Administration, not to mention the introduction of Ribbon.


    Sunday, June 13, 2010

    Fast Search Server 2010 for SharePoint Installation and Configuration

    The home page of Fast Search Server 2010 for SharePoint: is a must read in order to get started on this.

    I won't bore you with detailed steps setting up FAST on SharePoint for a development environment since above link has many pages of detailed instructions, I will just point out some issues I ran into and the resolutions of those.

    First, you can install FAST on SharePoint server. For my development environment, I have SharePoint 2010 and FAST on the same server, and databases are on a separate SQL server.

    After the installation, during the configuration, If you run into error about "Username or domain is incorrect", please use full domain name, please see this post on TechNet. You can use "ping -a servername" to find out the FQDN.

    After I have setup everything, I got the error message "The search request was unable to connect to the Search Service". After ensuring that the SharePoint certificate is copied to the FAST Search Server 2010 for SharePoint query processing node, the search works like a charm.

    Also I created a new site based on FAST Search Center template and made necessary changes to My Site and the Portal to ensure that SharePoint uses FAST as the search provider. Please see the bottom of this post for directions on this.

    Good luck with your FAST installation and configuration.


    Wednesday, June 9, 2010

    Using SharePoint 2010 Secure Store with Business Connectivity Services

    Great writeup on using SharePoint 2010 Secure Store with BCS by Fabian Williams.

    Job well done!


    External Content Types Error Message

    Using SharePoint Designer 2010, whiling trying to create a new External Content Types, I got the following error message while trying to expand the Tables/Views under the database:

    "Can't complete refresh"
    "Skipping the following table because it is not configured for use"
    "Line 1: Incorrect syntax near '('".

    The Routines folder expands fine.

    The data source type is SQL Server,  For SQL Server Connection, I have "Connect with User's Identity"
    What could be wrong? Is there a minimum SQL Server version requirement? The version for this SQL Server is 8.0.2050, SQL Server 2000 SP4. I can connect to another sql server with version "9.0.3054", SQL Server 2005 SP2.

    I unerstand that there is a minimum requirement for SQL Server for SharePoint. SharePoint Server 2010 requires that its database server must be a 64-bit version of one of the following: Microsoft SQL Server 2008 R2, SQL Server 2008 with Service Pack 1 (SP1) and Cumulative Update 2, or SQL Server 2005 with SP3 and Cumulative Update 3.

    It does look like the minimum requirement for SQL Server for BCS purpose is SQL 2005 or higher, according to this post. Also you  can work around this problem by using stored procedure or web services wrapper.

    Or maybe it is time to upgrade that sql server.

    Tuesday, June 8, 2010

    Using SharePoint 2010 Developer Dashboard for Debugging and Performance Monitoring

    Basically, we can use the following code pattern:

        using (new SPMonitoredScope("My code block (WebPart1)"))
            // the code to be monitored here

    Please see the blog from Waldek Mastykarz for detail.

    Wednesday, June 2, 2010

    SharePoint 2007 Auditing Feature, Site Collection Level Auditing and List/Library Level Auditing

    Quick steps:
    1. Create a policy at the site collection level: click on Site collection policies under Site Collection Administration of the site collection Site Settings.
    2. Within the same site collection, go to the list/library to be audited
    3. Go to Settings of the list/library, select Information management policy settings under Permissions and Management
    4. Select the policy from step 1
    Note: site collection auditing NEEDs to be enabled. Audit log reports is only available at the site collection level. And audit logs take additional content database space.

    Also there are 3 good article on MSDN about auditing:
    Don't forget to trim the audit log, this tool SharePoint Audit Log Tool from codeplex can help.

    Friday, May 28, 2010

    Using Session State in SharePoint 2010 - Mark Arend - Site Home - MSDN Blogs

    Very good article. In summary, it explains the difference between ASP.NET Session State and State Service and how to enable ASP.NET Session State and it's implications.

    If your custom SharePoint code uses ASP.NET session, please be aware of this.

    Link to the article

    Thursday, May 27, 2010

    Date Comparison in FullTextSqlQuery

    I found this forum discussion.

    Basically according to Steve Curran, the date literal must be surrounded by single quotes and formatted in YYYY-MM-DD format. Note this format does not address date with time value. However, even with this format, the = comparison does not work, for example, reportDate = '2010-05-24'. The >= comparison works.

    In order to make equal comparison work, I had to combine > and < together. For example:

    reportDate > inputDate.AddDays(-1).ToString("yyyy-MM-dd") and reportDate < inputDate.AddDays(1).ToString("yyyy-MM-dd")

    The reportDate is a Date and Time field with Date Only format.

    If you know any other approaches, please let me know.

    Update: Also find this blog by about datetime comparison. Must read if you do datetime comparison in custom search web part.

    Monday, May 24, 2010

    preupgradecheck Common Issue Resolution

    From George Khalil:

    Upgrading your Content DB to SharePoint 2010 – Part 1, The preupgradecheck

    Lots of great information on solving some common problems reported by preupgradecheck, such as missing site definition, missing feature, etc. 

    SharePoint 2010 Custom Error Page Implementation

    Todd's Blog | An Expected Error Has Occurred

    SharePoint Content Database Detach Attach Tips

    Recently I upgraded SharePoint 2007 farm from SP1 to SP2. I took the hybrid approach, i.e., I detached the content databases before the binary upgrade, then attached those content databases after the binary upgrade. All went well other than one issue and one interesting observation.

    The issue: for all the content databases, we have custom value for "Site Level Warning" and "Maximum Number of Sites", after detach and attach, the custom values are gone and I had to create a simple console application to update those values. I could do this manually via central administration, but we have many content databases.

    So don't forget to set those values if those values are customized.

    The observation: In Central Administration > Application Management > Content databases, you can set the value for Site Level Warning and Maximum Number of Sites to the same value, even the Manage Content Database Settings page says in red on the top "The database capacity setting values must be greater than the number of existing sites in the database, and warning site count must be less than the maximum site count.". Very strange. Maybe just a bug in the UI.

    Thursday, May 20, 2010

    Content Databse with Modified database schemas

    "stsadm -o preupgradecheck" reports that "Failed: Content Databse with Modified database schemas".

    Options to fix:

    • User SharePoint Central Administration to backup and restore the questioned content databases to a new content database.
    • Use stsadm mergecontentdbs to the sitecollections in the questioned content database to a new content database.

    Moving All SharePoint Databases to a New Database Server

    Using backup and restore. Here is the procedure from Steven Haden's Blog:

    1. Using the SharePoint Central Admin, make a full backup the whole farm.
    2. Start the SharePoint Products and Technologies Configuration Wizard and disconnect the web server from the farm
    3. Using the SharePoint Products and Technologies Configuration Wizard define a new farm in the SQL server, that creates a new configuration database
    4. (Updated) Using the SharePoint Central Admin restore the full backup in your new farm, running it twice. Select New configuration to be able to change the Database name.
      1. Restore first the content database
      2. Restore the SSP and its content
    Or this article from TechNet:

    Move All Databases

    When building a new farm, we should consider using sql connection alias to add a layer of abstraction between SharePoint servers and database server.

    Monday, May 17, 2010

    Laura Rogers:SharePoint 2010 – Where’d “My Links” Go?

    SharePoint 2010 – Where’d “My Links” Go?

    How to get My Links of SharePoint 2007 back in SharePoint 2010, sort of.

    Crazy SharePoint 2010 Database Names

    I just finished the installation and initial configuration of SharePoint 2010 RTM development environment on a 2 server environment, with all databases on a separate sql server 2005 server.

    By following the Farm Configuration Wizard, I was done in no time. However, a big drawback is the names of the databases created. I know how to rename content databases, including central administration content database, by way of detaching and re-attaching after database renaming. You can use CA UI for all content databases, other than CA content database. Since once the CA admin content db is detached, the CA UI does not work anymore. So to add the CA content db back, you need to use stsadm command, such as
    stsadm -o addcontentdb -url "url to the CA" -databasename "db name"
    Then the CA UI should be up and running.

    The challenge is how to rename or recreate those databases used by service applications with preferred naming pattern . Using Central Admin, I deleted the PerformancePoint Service Application, including the databases, then recreated the service application. However, there is no option to name the database during the creation process using CA UI.

    It looks like that the only way to accomplish this is to use PowerShell cmdlets, see

    I wish that Microsoft had made this easier for service application database names.

    If you have done renaming those service applications databases, could you please share your thoughts and procedures?

    Chris O'Brien: Tips for building SharePoint 2010 base VM images

    Chris O'Brien: Tips for building SharePoint 2010 base VM images

    SharePoint 2010 Training and Resources

    From Arpan Shah's Blog:

    With information on overview, for developer and IT pro.

    Friday, May 14, 2010

    People search not working, peopleresults.aspx page does not exist and people search webparts missing

    I have installed SharePoint 2010 and configured Managed Metadata Service, User Profile Service Application, Search Service Application and My Site settings. Also I created a web application with root site collection created with Publishing Portal template. Now I can search documents with no problem.

    While doing a people search, it fails complaining that http://server/search/peopleresults.aspx missing. Then I found this article about similar problem. I followed the steps and realized that those people search web parts, such as people search box, people search core results, are missing in my SharePoint environment. I also tried to enable a whole bunch of features but to no avail.

    Finally I found a workaround, here are the steps.

    * delete the search subsite created by the publishing portal template
    * create a managed path named search, you can name anything you want
    * create a site collection under the search managed path, with Enterprise Search Center template
    * change the My Site settings to reflect above change
    * change search settings of the portal root site collection to reflect above change

    I tried to create a subsite under root site collection, but only the Publishing templates are available. That is why I took the managed path route.

    Not sure why I ran into the problem at the first place and not sure anybody else experienced this problem or not. Hopefully this can help somebody out there.

    Tuesday, March 30, 2010

    Incompatible Web Part markup detected. Use *.dwp Web Part XML instead of *.webpart Web Part XML

    When developing web part from Microsoft.SharePoint.WebPartPages.WebPart class, we need to use dwp format, instead of .webpart format.


    Friday, February 12, 2010

    Work around OnTaskCreated activity to get TaskId

    Please see:

    Now I can get the taskid, however, emails are sent to the same receiver, or the task owner of the last task created in a replicator activity.

    Still trying to figure out how to resolve the email problem.

    Tuesday, January 26, 2010

    Backup and Restore SharePoint 2007 subsites

    2 options:

    1. use stsadm export and import. Type stsadm -help import or stsadm-help export for options. When import, make sure to import to a blank site. Also note some data in the subsite can't be exported, such as workflow related data. For example:

    stsadm -o export -url http://sitecollection/subsite -filename subsite -includeusersecurity -haltonfatalerror -cabsize 1023

    Note the cabsize switch works around the default 25 MB size limit. Also see for a good explanation of moving large subsite.

    2. user SharePoint Designer. There seems to be a 25 MB backup limit or bug.