Monday, February 15, 2010

Creating custom field with multiple line of text (object model)

If we want to create field multiple line of text through object model then we can use SPFieldType.Note(this will create multiple line of text column).
If we create with SPFieldType.Text then it will be single line of text.

Tuesday, January 19, 2010

Cannot insert the value NULL into column Name

This problem will arise when activating event handler/not sure about other feature.
The reason behind this is the commented code in the element.xml. After removing the commented code the feature will be activate sucessfully.

Tuesday, January 12, 2010

Using Objects in Event Receivers

Event receivers that instantiate SPSite, SPWeb, SPList, or SPListItem objects instead of using the instances passed via the event properties can cause the following problems:

They cause additional roundtrips to the database. (One write operation can result in up to five additional roundtrips in each event receiver.)


Calling the Update method on these instances can cause subsequent Update calls in other registered event receivers to fail.

Sunday, December 27, 2009

Sharepoint Articles links

How to optimize a sharepoint server 2007 with Web content management
1) http://msdn.microsoft.com/en-us/library/bb727371.aspx
2) http://msdn.microsoft.com/en-us/library/bb727372.aspx

10 steps to building XHTML compliant and performing MOSS publishing sites

http://blogs.code-counsel.net/Wouter/Lists/Posts/Post.aspx?ID=103

Best Coding practice while working with object model
http://msdn.microsoft.com/en-us/library/bb687949.aspx

Fire fox css issue
http://www.webmasterworld.com/forum83/7738.htm

Friday, December 18, 2009

Feature Stappling

Suppose when the site definition is already in use (and sites have been created) modifying a site definition once it has been deployed, since the site definition files on the filesystem are used for pages which are ghosted (not modified).
At this time we can go with feature stappling.
Some times it is also knows as site template association.
So finally feature-stapling Feature provides the mappings between the Feature and site definition.

Thursday, December 17, 2009

How to check the List Template Id in sharepoint site

Its difficult to find the list template Id of the page library in publishig site.
So in order to check list template Id of Page library or Image library follow the steps.
1) Open http://site/pages/forms/allitems.aspx
Check for view source of the page.Search for the keyword ctx.listtemplate, there you will find the list template id for the pages library.
Same thing do it for Image library also.
Some of the important template id are as follows.
Value
Description
100 Generic list
101 Document library
102 Survey
103 Links list
104 Announcements list
105 Contacts list
106 Events list
107 Tasks list
108 Discussion board
109 Picture library
110 Data sources
111 Site template gallery
112 User Information list
113 Web Part gallery
114 List template gallery
115 XML Form library
116 Master pages gallery
117 No-Code Workflows
118 Custom Workflow Process
119 Wiki Page library
120 Custom grid for a list
130 Data Connection library
140 Workflow History
150 Gantt Tasks list
200 Meeting Series list
201 Meeting Agenda list
202 Meeting Attendees list
204 Meeting Decisions list
207 Meeting Objectives list
210 Meeting text box
211 Meeting Things To Bring list
212 Meeting Workspace Pages list
300 Portal Sites list
301 Blog Posts list
302 Blog Comments list
303 Blog Categories list
1100 Issue tracking
1200 Administrator tasks list
2002 Personal document library
2003 Private document library

Deploying event receivers

There are 3 ways we can deploy the event receivers.
1) Deploying Programatically
2) Via Feature
3) With Content type

Programatically
This can be done only when an event receiver need to be associated with a single instance of a list rather than with all list of with template ID.

With Feature
Programmatic deploying will install the receiver againest a specific instance of a list and much reuse benefit is not possible in this.
To overcome this we can use this method.


Before creating any event handlers developers should think following points.

1. Security:

The assembly you deploy to the Global Assembly Cache(GAC) is running with full trust. Watch out for the following:



· Denial of Service attack: If a user uploads 10000 items to a list, what is the effect it will have to the systems your assembly uses.

· SQL Injection attack: If a user attempts to insert SQL statements into a column of a list that your assembly uses to update a database, what mechanisms are you using to make sure the input is valid.

· Cross Site scripting attack: What is the effect of adding script to a column that your assembly uses to update another area in SharePoint?



2. Performance:

Watch out for the following:



· Load: What burden are you placing on your web front end servers to run the assembly each time an event occurs? Use performance counters to determine this.

· Long Running Operations: Consider creating a custom SharePoint timer job. Kick off/ Schedule the Timer Job from the event rather than running all the logic inside the event. This will allow you to use the features of SharePoint to view whether the Timer Job ran successfully.

· Sync vs Async Events: Synchronous events have to wait until your code completes before returning the page, whereas Asynchronous events show the page immediately.



3. Error Handling:

When using synchronous events and you decide to cancel an event, let the user know why the event was cancelled. For example, update a Task List with a message why it failed.



Log your errors so that you can determine what issue is occurring when your system is in production environment.



4. Connections: Cater for external systems being down when you are trying to connect to them. Don’t let your code / solution go belly up because you cannot connect to a database.



5. Bulk Operations:

The MSDN documentation mentions that event handlers will not fire when bulk operation is occurring. For example, when a new list is created, the FieldAdding event will not fire.

Limitations of Event Handler in SharePoint

Strangely there is no “SiteAdding”, “SiteAdded” event. However, if you really need this event you could create a “feature” to accomplish this. Features in SharePoint have a “FeatureActivated” event, where you could perform an action on creation of a site.