Thursday, April 23, 2009

Add People Picker and Date Time Control

Issue: Add WSS DateTimeControl to a custom application page.
Solution: Firstly include below tag for SharePoint assembly in the application page on top.

<%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

DateTimeControl Tag:

<wssawc:DateTimeControl ID="DemoControl1" runat="server" DateOnly="true"></wssawc:DateTimeControl>

People Picker Control Tag:

<wssawc:PeopleEditor ID="OSAccountContact" runat="server" MultiSelect="False" SharePointGroup="OS Global Delivery India" ValidatorEnabled ="true" />

Similarly,you can add other SharePoint Control also in custom application pages.
Note: The PeopleEditor Control will give object reference error when run in aspx pages. Also the DateTimeControl will not show error in aspx page but will not show calendar control for picking the date. You need to add it as a user control or webpart into a sharepoint site to test it and use it.




Error when click on EditForm.aspx in SharePoint custom list


Issue: When clicking on EditForm.aspx of a SharePoint list it redirects to below page with error message "Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries."
Reason: The SQL query passed when opening EditForm.aspx is getting multiple values for some field/fields of the list. This may be possible if you are updating some of the columns in list through workflow. Specially when the columns are lookup column or choice column. When SQL query is run on EditForm.aspx, it will return one value updated through workflow as well as another default value of choice field. Once the list item shows this error it gets corrupted.
Solution: Include all the values updated through workflow in the choice list of the column. In this case, workflow updates the column value which will be one of the choice and hence multiple values will not be fetched through SQL query.
Hope this works for most. As it solved my issue which i was getting since many weeks.