Creating and Using a New Column Type
August 13, 2007
Over the past weeks, I've been talking about column types and content types in Microsoft Office SharePoint Server 2007, and why you'd want to use them. This week, I'll show you the actual process for creating a new column type, so let's dive right in.
Creating and Using a New Column Type
To get started, you’re going to need a sandbox site to work in, so if you don’t already have one, create it now.
Then, in your new site, go to the Site Actions menu and choose Site Settings.
You'll be taken to the Site Settings page, where you'll see the Site content types and Site column options.
Under the Galleries category, select the Site columns option. You'll be taken to the Site Column Gallery page which contains a list of all the column types defined for the current site and portal. Column types are a site-level resource and are available only at the level where they are defined and lower.
It's recommended that you don't change any of the existing column type definitions in this gallery. Doing so may have a negative impact on your portal. The recommended and best practice approach is to create new custom column types for your specific needs.
At the top of the Site Column Gallery page, you'll see a link labeled Create. (You can probably guess what it's for.) So click it and let’s create our first new column.
The first thing you're prompted to do is give your new column type a name and data type. For demonstration purposes, enter Risk Source as the name and Choice as the data type. The next section allows you to specify how the new column type will be grouped. I prefer to group my custom column types under the name of my company (e.g., ShareSquared Custom Columns). The next section lets you specify additional settings for this new column type. I gave my new column a description, did not make it required, and added two new choices: Design and Planning. After you've completed all the necessary fields, click the OK button and your new column type will be created.
If all went well, you should now be back at the Site Column Gallery page. Scroll down the page until you locate your new Risk Source column type. The left column contains the column type name, the middle column contains the data type, and the right column contains the site for which the column type is defined. As I mentioned earlier, column types are a site-level resource, so where you create it will determine who can access it.
Now let’s put this new column type to use. First, we'll create two custom lists and name them Risks1 and Risks2. In a real world scenario, I wouldn’t have more than one risk list on a project site; however, I'm going to demonstrate what happens when we make a change to the column type definition. So go ahead and create the two lists.
For each of your custom risks lists (Risks1 and Risks2), perform the following steps:
1. Go to Settings, List Settings.
2. In the list schema section, select the Add from existing site columns option. You will be taken to the Add Columns from Site Columns page.
3. Select the group name you gave your column type during the creation process.
4. You should now see your custom Risk Source column type listed. Add it to the Columns to add list.
5. This is optional, but you can add a couple of items to your list. As you will see, the two items (Design and Planning) you added to the Risk Source drop-down menu are now available.
Using the same steps as described earlier, go back to the site Column Gallery (i.e., select Site Actions, Site Settings, then Site columns). Locate your custom column type and click Risk Source. Now update the choices to include Budget. Before you click OK, make sure the Update Lists radio button is set to Yes.
Click OK, then go back and see how the change was propagated to the Risk Source column in both Risks1 and Risks2 Lists.
Now tell me this isn’t a great feature. Think of the hours saved!
About the Author
You May Also Like