Jan 29, 2010

New SPD, Old Story with Data View

When creating Data View Web Part to connect with external data source, the following is the most infamous error you might get:

"The server returned a non-specific error when trying to get data from the data source. Check the format and content of your query and try again. If the problem persists, contact the server administrator"

Karine Bosch's Blog is the best to describe the root of this problem. Even though it was written for last version SPD, it still works for SPD 2010 with its second solution (only): use stored procedure.


a small side note, you can always see details of each Data Sources in _catalogs/fpdataSources/ folder. Some people said it is the way to work around connections to non-sql DB. Also, using window connection to SQL is not allowed for a good reason:it will be treated as double hop.

Jan 27, 2010

Using SharePoint PowerShell with intellisense

With thousands of cmdlets in SharePoint PowerShell, it is almost impracticable to use PowerShell without intellisense, for this reason, I posted the question on how to get intellisense for SharePoint PowerShell on Twitter, LinkedIn SP groups, MindSharp Mailing list, but didn't get response back. Turns out it is not that difficult, but in case someone needs a quick reference, here is the things you need to do:


First Download Window PowerShell V2.o to install PowerShell ISE (UPDATE:  ISE is installed in  window 2k8 R2, just need to activate as feature You will find it in All Programs -> Accessories ->Windows PowerShell)



Follow this post to load SharePoint snap-in into Window PowerShell ISE

Use intellisense by entering Tab key


One twist is, after using index, such as Lists["shared documents"], intellisense stop working, as a workaround, $list=$siteCollection.RootWeb.Lists["shared documents"], intellisense will work after $list.

Jan 21, 2010

Security in SharePoint Client Object Model

Available authentication types for managed .net client OM include:
  • Anonymous
    web applications need to be anonymous and Client OM permission requirement need to be unchecked as well:

    Even so, some operation like list.getitems(query) are blocked for undocumented reasons.
  • Default (Window Authentication)
  • By default, both .Net Client OM and Silverlight Client OM use window authentication, and credentials are passed through, i.e, sharepoint will authenticate the user who is running client applications.
      For web client application, when debugging in VStudio (F5), it is account running VStudio that will be passed, but for IIS sites, it is either App Pool ID (by default, no impersonation) or user login in account( when impersonation enabled) or anonymous accout (when anonymous enabled)
    • FormsAuthentication



    Addition security restriction:



    • ECMAScript Client OM can only access SharePoint data for current site, no cross site scripting allowed (no place in ECMA OM you can pass credential ). That means ECMAScript Client OM can only be used in SharePoint context, such as application page, web part, and dialogue.
    • Silverlight Client OM can only access resource from the same domain unless explicitly defining clientaccsspolicy.xml.

    Jan 17, 2010

    Load CDN hosted JQuery

    Since loading JQuery libraries from Content Delivery Network (CDN) has many advantages over hosting locally, I adopt this approach today by using script tag as:
    <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.js" type="text/javascript" > </script >

    I didn't expect any problem in doing that, but to my surprise, I kept getting "object expected" error on VStudio debugger. I tried with Google CDN, same error.

    The error indicates that JQuery is not loaded, but what causes it? It turns out this IE setting is the reason, somehow "Active Script" is disabled in my Win2k8 Web(SharePoint 2010) Server:


    Don't believe this could be a common case, but it proves CDN hosted JQuery relies on browser settings, and can fail. So the best practice is to always provide a failover to local JQuery libraries.

    Jan 11, 2010

    debugging SharePoint Silverlight Client OM code

    I have created a Silverlight application in VStudio 2010 (Beta 2) and wired it to sharepoint by using Silverlight Client Object Model. With F5 debugging, the code in ClientRequestEventHandler (OnSuccess) can't be hit:

    ctx.ExecuteQueryAsync(OnSuccess, onFail);

    However, if I put the .xap file in sharepoint _layouts folder, and link it to sharepoint OOB silverlight webpart, the code in the eventHandler are executed well. Even though that doesn't help to debug the silverlight application, it does give me a clue why running from VStudio doesn't work with SharePoint Client OM.

    Silverlight, as a client technology, has limitations on crossing domain access. With sharepoint lives in http://localhost/, and Silverlight test web lives in http://localhost:randomPort , that is treated as crossing domain access. To verify this, under sharepoint iis root path, i create a clientaccesspolicy.xml file. I can then debug into the EventHandler Callback code with VStudio F5. Works like a charm!

    Another anonymity is, when hosting silverlight app by using OOB Silverligh webpart, after updating .xap file, you have to also delete the browser's cookie to see the refresh.

    Jan 6, 2010

    SharePoint 2010 Reusable Workflow

    SharePoint 2010 (beta 2) has 3 kinds of workflow based on association:

    • List WorkFlow: associated with a list
    • Site WorkFlow : associated with a site
    • Reusable WorkFlow: associated with a content type or site column

    Since it is associated with either content type or site column, the Reusable Workflow accompany the same content type or site column across the whole site. It can't be associated directly with lists nevertheless. When Reusable WF is associated with a Site Column at design time, the site column need to be added into a content type first, and then the WF can be associated with that content type.

    Reusable WF can only be created in SPD (WF created in VStudio are always reusable), but it can be imported into VStudio as a list workflow and become reusable in a site collection scope. In Beta 2, Reusable WF automatically has a init form once it gets published, and it is not converted after Reusable WF get imported into VStudio. Te following problem occurs at workflow run time:

    " _layouts/... . /IniWekfllp. aspx " not found.

    Creating a Init From in VStudio can get around this problem.

    Jan 4, 2010

    SharePoint Workflow: onTaskChanged inside While Activity

    It is a common use to put onTaskChanged activity inside a While loop in a ShaerPoint Workflow, but unlike normal scenario where you can directly access its AfterProperties or BeforeProperties, both of them are null when onTaskChanged activity in a while loop. To get around this problem, OnTaskChanged activity needs to have both AfterProperties and BeforeProperties bind to either a field or property. This is not necessary though if onTaskChanged is not inside a While activity. I found this with Visual Studio 2010 beta 2, and I will verify it with new realease of VS 2010.

    Jan 1, 2010

    deploy sharepoint solution in Visual Studio 2010 (beta 2)

    When deploying a sharepoint solution from Visual Studio 2010 (beta 2) it fails in the step "recycle IIS Application Pool", and in the Event Viewer, there is an error saying:

    "SQL database login for 'sp2010_SharePoint_Config' on instance 'spsql' failed. Additional error information from SQL Server is included below."

    Most likely it is because the window login account IS a local Administrator account And it doesn't have permissions on either configuration db or content db. Unfortunately this is a quite common case though. VS only prompts to "run as Adminstrator" if window login account is NOT a local Administartor account. In other word, if user login as a non-adminstartor account, VS will prompt user to run VS "run as administrator", and user has a chance to choose a farm account or service account to run VS. But if user login as an account with local administartor privilege, VS won;t promot even if the login account doesn;t have sharepoint db permission.

    This also means you can't run VS as a local account to deploy sharepoint solutions unless SQL sits in the same box.