views:

248

answers:

2

I created a custom field for a content type I am creating using the XML below.

<Field ID="{GUID}" Required="False" DisplayName="Likes" Name="Likes" Type="Number" SourceID="http://schemas.microsoft.com/sharepoint/v3"&gt;&lt;Default&gt;0&lt;/Default&gt;&lt;/Field&gt;

The field is meant to be used as a counter of sorts, and will be incremented programmatically. But, I can't get the value to default to "0" when a new item is created. However, for some reason, when I create a new column manually using the Site Collection settings page and configure it to default to "0" it works as it should.

So far, I've tried the following tactics:

  • I removed the "default" element from the field definition, and set the "DefaultValue" attribute on the content type definition.
  • I exported a definition for the manually-created, working column (using an Imtech STSADM tool). Then, I added it to my field definitions XML and modified the IDs so that I could add it to my content type. When I did this, it still didn't work, even though it was exported from a working column!

Any idea why this isn't working for me?

A: 

Other than case (it's Default, not default), it looks good to me. Also, maybe you could try Integer or Counter for Type instead of Number.

Rich Bennema
Right, sorry about the case, I re-typed it by hand since my development actually occurs on another machine without Internet access. I'll update the example.
UnhipGlint
A: 

The cause of this issue was that my custom content type (the one that contained the number field) was not set as the default content type for the Pages list. I was most likely creating page items using a different content type, accidentally.

UnhipGlint