Archive for category Code

Exporting a SharePoint Site Collection to XML

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

This is a repost of something I did on the MSDN SharePoint 2010 forums covering a method for exporting data in a SharePoint site collection to XML. Note that this example does not cover exporting documents or storing navigation/web part settings. It just exports structure and all list items. So if anyone else has a use for this they can use this as a starting place. 🙂

2 Comments

Bulk Loading Profile Properties

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

So, I got asked this morning for a simple way to bulk load and map user profile fields so that profile properties could easily be copied from one environment to the next. Makes sense, so I built a little command line tool that reads an XML file for doing just that. When I was about mid-way through I remember Gary Lapointe had already built a tool that does exactly the same thing! So I scrapped what I was doing and recommended his excellent tools for doing the job. However, I thought it would be interesting to at least show how this stuff all works. 🙂

No Comments

Handling Feature Dependencies

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

So a common scenario is you have to deploy a set of features to get a desired result. However Feature B is reliant on Feature A and you want them to auto-activate. However automatic activation in this scenario generates an error if Feature A hasn’t finished being activated yet.

5 Comments

Updating Items Safely in an Event Handler

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

This caused me lots of headaches a few months back, the SharePoint application pool was randomly crashing and the SharePoint logs were showing list item contention on updates. Eventually it all came back to the event handlers we had running within that site collection and an unpublished best practice for how to safely update list items from within item events.

No Comments

Long Running Operations within an Event Handler

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

So, often times when you have an event handler you have to do something that takes longer to execute than SharePoint normally allows for within an event handler. Now normal multi-threading sometimes works here, but often times also runs in to the issue where SharePoint terminates the event as timed out. So here’s a trick I’ve found that works.

15 Comments

Using Native SharePoint Form Fields

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

When making a generic web part for modifying or interacting with different SharePoint data you can’t always predict the column data type before hand. The best way to make sure your web part works regardless of what data is being tossed in to it is to just use the out of box SharePoint Form Field control. This control goes ahead and grabs the column edit and display templates depending on the state you specify. Below is a code snippet example of how to use this control. Takes a lot of the headache out when dealing with unknown data types/building generic web parts.

No Comments

SharePoint Search with Pagination

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

This is an example class for showing how to search SharePoint with paging support in the API. This function accepts a string containing the standard SharePoint SQL style search query.

1 Comment