Saturday, July 31, 2010

A bit more about custom field types and XSL

The following are the attributes you can use in XSL to identify the field you want to change (or access the value of):

  • Name (example: "First_x0020_Column" - the internal name of the column - not the field type!)
  • Type (example: "Text" - the base type of the field type)
  • FieldType (example: "MyCustomFieldType" - the type name of the custom field)
  • DisplayName (example: "First Column" - the title of the column
  • ID (example: "1b858cea-4306-4cf9-91e8-8bb8674dcdf4" - the GUID for the current column

Applying a XSL stylesheet to a custom field

In the MSDN walkthrough and examples on using XSL to create a custom rendering style for a custom field type, the sample XSL all use the field's name as the reference. This is a bit silly - since it means the users need to create the new fields with the exact same name.

While the option to create a custom rendering based on the field name is welcome and will be very useful (if for example I am deploying a column to a farm and I want it to have a unique rendering template), the articles do not explain how to create a XSL rendering template for a field type - regardless of what the fields created from that type are called.

The solution is simple. Lets say your field type is "MyFieldType", then instead of the following line that uses the title of an instance of the field ("my field type"): <xsl:template match="FieldRef[@Name = 'My Field Type']" mode="Text_body"> use the following line instead, which uses the type name of the field: <xsl:template match="FieldRef[@FieldType = 'MyFieldType']" mode="Text_body">

Monday, July 26, 2010

5 Days SharePoint Development Training - Canberra, 16th August, 2010

Are you in Canberra on the week of the 16th, and is just itching for some sharepoint 2010 developer training? look no further!
I have teamed up with my friends from Synergy to deliver the first ever Synergy SharePoint 2010 Development course. For more details on the content of the course and how to register, head to Dimension Data's web site!

Tuesday, July 13, 2010

New look for the blog

Do you like it? Blogger has some new templates, and I figured its time for a change.

Update: following some comments, I reverted to white background again - and removed the width restriction that pissed me off. Is this better?

Monday, July 05, 2010

"The local device name is already in use" error when using AddFieldAsXml

I had the following exception thrown at me today when trying to add a site column using AddFieldAsXml method: "The local device name is already in use".
The reason was that my XML contained a field ID - which is what the XML for a field is supposed to have when it is used as an element file in a feature, but not when you are adding the field using code. So - beware!

Thursday, July 01, 2010

Read my book on Rough Cuts

Do you want a preview of my upcoming book - the 'SharePoint 2010 How To'? simply go to Safari books online and read away! There is also a purchase option if you like what you see...