Development

Development

Debugging Excel Services UDFs using Visual Studio 2010

Debugging UDF’s is not quite as simple as debugging other SharePoint artefacts. The UDF is called by the Excel Services service application which runs as a separate process. Bearing this in mind we have two options, we can either attach our debugger to all instances of the w3wp.exe process, or we can find out which process is being used to run service applications on out server. Discovering the ProcessID used to run a User-Defined Function Even though I’m sure that everybody will take the lazy option of attaching to all worker processes, here’s how we can find out...

Programmatically Set Item Level Security in a Document Library

December’s looking a bit bare on my blog calendar. I thought I’d better add something before the festivities begin. In truth I’ve been pretty busy over the past few weeks. I spent a few days doing an excellent CTT+ course at Rezound in Sheffield plus I’ve also just started work on a new SharePoint 2010 book for McGraw-Hill. That’s not to mention my outstanding commitment to Wrox to deliver a short e-book on SharePoint 2007 Packaging and Deployment, my ongoing development work and the joys of having two children, one of which hasn’t quite grasped the concept of sleeping yet!...

HowTo: Read Workflow Status Text

Ever wanted to be read the Status text displayed on WrkStat.aspx programmatically so that you can make use of it elsewhere? No? Can’t blame you! However, let’s say that you do fancy a bit of masochism. Here’s how it works: The status value is stored in a field of type SPFieldWorkflowStatus. Generally this field has the same display name as your workflow although it’s internal name will be different. Getting the internal name is a pain, for some bizarre reason Microsoft decided to expose this as an internal property rather than public. (See SPWorkflowAssociation.InternalNameStatusField). After...

VirtualPC – Tab key stops working

Like most developers, I use VirtualPC for development using different images for each client/configuration. It’s a setup that works well. However, while typing away this morning in Visual Studio, lo-and-behold the Tab key stopped working! You might think that’s not the end of the world, surely a niggle rather than a full blown DEFCON 1 problem but I guarantee if you try to type more than 10 lines of code in Visual Studio without the services of the Tab key you’ll find out how irritating a problem it actually is! No tab = no keyboard control of Intellisense. ...

DataBinding to SPListItemCollection

This is one of those things that I always forget about and end up having to debug. (Also for those planning to do MCTS, I guarantee that there will be a question about this one ;) ) While it is technically possible to databind to a SPListItemCollection, when you try to refer to any of the SPListItem fields by name you’ll end up with an error similar to this: [ArgumentException: Value does not fall within the expected range.] Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName) +161 Microsoft.SharePoint.SPListItemCollection.GetRawValue(String fieldname, Int32 iIndex) +56...

Formatting values in a Publishing Page

SharePoint Web Content Management is a pretty flexible beast, if you’re mad keen on writing code (and the ‘ole packaging and deployment curmudgeon), you can make it do pretty much anything. However, some times there are simple things that you’d like to do without having to crank up Visual Studio and start hammering out some angle brackets. One of these simple things is formatting values on a publishing page, particularly dates and Boolean values. If you’re reading this, you’ve probably made the same journey as me: Denial – There must be an easy way to do this, it’s so simple...

Custom FieldTypes – Part 3

Download the source code for this project here Over the last 2 posts in this series we’ve looked at creating a new field type to handle Xml data. We’ve created a basic implementation and added a custom user interface to make editing the data a bit more friendly. In this article we’ll look at using XSD and XSLT data to provide a higher level of data validation and to give a greater degree of control over how our data is displayed within SharePoint. Previously most of the code that we’ve added has been to the BaseXmlField and SPFieldXmlBase...