The community for Microsoft Office SharePoint Server champions!

Using SharePoint Designer to help with creating content types and columns XML/CAML

The other day I had to create a content type with several complex calculated columns.  I was deploying my content types to the server via a solution deployment pack (and features) and left starching my head on the correct CAML to correctly mark-up a calculated column. 

I know I could create the column in the web UI, but how was I going to get it into a feature and XML.  So it was time put my Elmer Fudd hat on and go hunting wabbits and see how I could easily extract a existing content type and it’s columns.  A quick search on Google did not help, I throughout about looking at the SQL DB’s but my head started to hurt just thinking about all the tables and columns I would need to search through.  There had to be a easy option out there, and SharePoint Designer (SPD) was it.  I have insert some basic steps to follow below to extract the XML for a content type and columns via SPD.  Using this method can also give you a better understanding as a developer the things you can do with SharePoint via CAML, and lets you see how Microsoft got it working.

Step to extract a content type and columns to CAML (XML)

1.       Create you content type and columns in the web UI.
2.       Create a list/library item using you new content type.
3.       Load up SPD to the site where you created you item.
4.       From the File menu click Export -> Personal Web Package.
5.       In the export web package window select the list/library where your create the item using the new content type and click add.
6.       Save the package to your local drive.
7.       Next browse to where you saved the file and rename it from .fwp to .cab.
8.       Extract manifest.xml to your local drive.
9.       Load the file up in your favourite XML viewer (might take a second or two it can be a large file).
10.   Navigate to the UserLists/Field node (Solution/UserLists/Fields).
11.   The within this node look for your field, you will be able to see the CAML that describes your field.

As you can see SPD can be a very powerful tool, and looking more at the manifest.xml file will also give you hours of extra reading.  When you save a list or web as a template you can do the  exactly same thing just rename the .stp file to .cab and extract the manifest file.

Note: Using the SharePoint Visual Studio add-in could help archive a similar outcome, however SPD can be a quick and easy tool to use.

 

Happy hunting.

Published Friday, 1 June 2007 1:50 PM by craig

Comments

 

Mirrored Blogs said:

Additional category: CAML Here is a great posting by a fellow named "craig" on a technique

September 9, 2007 2:52 AM
Anonymous comments are disabled