Archive for category 2007

Simple SharePoint Code Reference

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

This is a short example doc I built for a certain vendor that was having issues with some event handler code covering safe calls for doing a lot of basic SharePoint functions. Posted here for reference using System; using System.Net; using System.Diagnostics; using System.Collections; using Microsoft.SharePoint; using Microsoft.SharePoint.Navigation; using Microsoft.SharePoint.Publishing; using Microsoft.SharePoint.Administration; using Microsoft.SharePoint.Taxonomy; using […]

No Comments

Hide the ‘Attach Files’ Option

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

So I got asked today for a way to block end users from attaching files to list items on a particular list. So I whipped out jQuery and quickly wrote a little selector to hide that page region.

5 Comments

Checking File Status in an EventHandler

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

So a common issue people run in to with file driven event handlers in SharePoint is that the event handler triggers on the SPListItem being added not the file write completion. So oftentimes you’ll get odd issues where unpredictably you won’t be able to access the file within your event handler (typically a NullReferenceException). So here’s a simple example for how to see if the file upload has been completed and added successfully to the list item.

No Comments

Programmatically Add a File in SharePoint

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

A simple demonstration function to add a file to an existing SharePoint Library.

10 Comments

Programmatically Set Permissions

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

This is some example code I wrote the for the MSDN forums to showcase how you can programmatically set permissions. This code will work for splists or spwebs (in the example it’s SPList permissions, but just changing those calls to go off of Web will switch it). In addition, this shows how to set permissions automatically at feature activation using a SPFeatureReceiver. Double bonus! 😉 Read on for code!

2 Comments

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