SharePoint Custom List Definition Recipes

If you want a tutorial on how to create a custom ist definition in SharePoint, check MSDN or Andrew Connell’s post. Here, I’ll just provide several short recipes for some scenarios.

1. How to rename the Title column in the list definition?

Often, you want to rename the Title column in your list definition. Don’t do it, because many internal SharePoint functions requires it. Instead, just change the display name of the column.

You need to do this in the list definition’s schema.xml, not in the content type definition file. In fact, don’t mention the Title column in the content type. If you do, the Title column will appear twice in your list.

Here is what you should modify in your schema.xml:

<Fields>
	<Field ID="{82642EC8-EF9B-478F-ACF9-31F7D45FBC31}"
		   Type="Computed"
		   Name="LinkTitle"
		   DisplayName="My Own Title" />
	<Field ID="{BC91A437-52E7-49E1-8C4E-4698904B2B6D}"
		   Type="Computed"
		   Name="LinkTitleNoMenu"
		   DisplayName="My Own Title" />
	<Field ID="{FA564E0F-0C70-4AB9-B863-0177E6DDD247}"
		   Type="Text"
		   Name="Title"
		   DisplayName="My Own Title"
		   Required="TRUE" />
	<!-- Other fields declaration -->
</Fields>

Keep in mind that you will need those three columns declaration, one for the plain Title data, the others for the Title with link and menu which are displayed in the standard form. You can put your own text inside the DisplayName attribute.

2. What are the required attributes in the List and ListTemplate elements?

The List element in schema.xml is similar to the ListTemplate element in the feature manifest in the sense that they both have a similar set of attributes. A lot of attributes are duplicated and it often cause confusion. Usually, I would put every attributes I needed in both elements. But this is not a good practice, since if you need to change some attributes, you have to do it for both elements. So it’s better to put only the required attributes in each element. What are they?

MSDN actually has listed the required attributes for the List and ListTemplate elements. But, at least in my case, it’s not so accurate. So here is what I found:

Required on the List element:

  • BaseType
  • Direction
  • Name
  • Url
    The MSDN article suggested that this attribute is optional. But if you don’t include this, you might get the following error when creating an instance of the list:
    Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))   at Microsoft.SharePoint.Library.SPRequestInternalClass.CreateListFromFormPost(String bstrUrl, String& pbstrGuid, String& pbstrNextUrl)
    at Microsoft.SharePoint.Library.SPRequest.CreateListFromFormPost(String bstrUrl, String& pbstrGuid, String& pbstrNextUrl)

Required on the ListTemplate element:

  • BaseType
  • DisplayName
  • Name
  • Type
  • http://cs.vbcity.com/blogs/skullcrusher Andy Bonner

    Nice post.

    Just so you know you can rename the Title field in your Content Type like this

    Just make sure it’s only the DisplayName you change and NOT the Name.

    You still need to make the changes you mentioned in your List Definition but I like to have the Content Type title have the display name i want as well.

  • denni

    Hi Andy,
    Thanks for the response.
    Actually, when I tried to change the Title field’s display name in the content type definition, the list referencing the content type will end up having two Title fields.
    Did this not happen in your case?

  • http://fischundmeeresfruechte.blogland.com.au/ conrad i. arnold

    Hey i have wondered how much you would bill to set your blog graphic up on my web logs for me, because i really like the look of your web site but i do not know how to do such a nice graphic.

  • denni

    Hi conrad,
    I’m using a theme designed by Chris Wallace, you can find the link on the bottom of this page :)

  • Hemant

    Hi,
    When I changed the DISPLAYNAME of the TITLE Column it is affecting in all lists on the web site.
    am i doing something wrong?
    Following is my FIELD definition.