views:

2004

answers:

6

"Title" field is sealed. Any attempts to update the default value resets the value back to "null"

+2  A: 

Hello,

You can RemoveFieldRef and FieldRef it right back in. In fact, the document content type does this itself to make the title not required. In the default ctypeswss.xml there is no sealed attribute set on the Document content type.

Check out [12]\TEMPLATE\FEATURES\CTypes\ctypeswss.xml and scroll down to about line 32 to see how the content type does this.

.b

(Disclaimer: I am running a high fever, so if I don't make any sense, blame the lollipops running around my kitchen)

Bjørn Furuknap
A: 

Hi Bjorn

Thanks for your time.

Your idea of doing "RemoveFieldRef and FieldRef it right back in" would be the same as setting the properties "Required" and "Default Value" through the interface for the "Document" or inherited content types though your idea would help if we are building custom content types.

Setting "Title" to required does not work in all situations. One such situation is when you try to add a item through "New" (which in my case opens up a template based on office 2007).

Since "Title" as required field was giving me hard time, I wanted to try the "DefaultValue" route but even this one does not seem to work. Any help?

Ganesha
Thanks for your question as it's a good one! Just a note that you might have realised by now Stack Overflow is not a forum site. Rather than writing another 'answer' to the question which this isn't, just add comments to other peoples answers. Thanks again!
Alex Angas
A: 

Hm... If you are not doing custom content types then I would suggest doing what you want through a feature receiver. You can attach that receiver to the default document content type and handler your columns as you like, for example setting default values or only setting default values if no user value has been provided.

.b

Bjørn Furuknap
A: 

This approach works for all fields except for hidden "Title" field which seems to really special

Ganesha
I am starting to think you have something really strange set up if you both have the title set to sealed and hidden. In a default setup there is nothing that hides or seals the title field. Note that you must update SPListItem["Title"] and not SPListItem.Title as the latter is read-only.
Bjørn Furuknap
+2  A: 

Do this with a Event Reciever that you register with the Content Type for Items Added and Items Updated Events. This way whenever a new Item is added it can be given your default Title. You can register Event Recievers in the Content Type CAML like such:

  <ContentType ...>
    <FieldRefs>
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" DisplayName="My Title" Required="FALSE" ShowInDisplayForm="FALSE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInListSettings="FALSE"/>
    </FieldRefs>
    <XmlDocuments>
      <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events"&gt;
        <Receivers>
          <Receiver>
            <Name>TitleCreator</Name>
            <Type>ItemAdded</Type>
            <Assembly>...</Assembly>
            <Class>TitleCreatorItemEventReceiver</Class>
          </Receiver>
          <Receiver>
            <Name>TitleCreator</Name>
            <Type>ItemUpdated</Type>
            <SequenceNumber>1</SequenceNumber>
            <Assembly>...</Assembly>
            <Class>TitleCreatorItemEventReceiver</Class>
          </Receiver>
        </Receivers>
      </XmlDocument>
    </XmlDocuments>
  </ContentType>
stlawrence
should be possible for almost all fields. The default "Title" is a true exception. See below for the explanation
Ganesha
+1  A: 

This is what we have found for "Title":

  • The “Title” field is not sealed in fieldwss.xml (12\TEMPLATE\FEATURES\fields)
  • It’s not sealed under “Document” content type in ctypeswss.xml (12\TEMPLATE\FEATURES\ctypes)
  • It is sealed in Document library definition in the schema.xml (12\TEMPLATE\FEATURES\DocumentLibrary\DocLib)

Setting default value through OM would reset the value to NULL on content type .Update(). This is because "Title" is sealed in the DL definition.

Opened a service request with MS. Waiting for the results!!!

Ganesha
No updates from MS yet!!!
Ganesha