4

I've created a list in sharepoint by using visualstudio. The List is based on a custom contenttype. Because I want to delete the title field I've switched off inheritation of the Contenttype:

 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Field ID="{51CC6776-F855-48d5-A4EC-B7CE11CE2324}"
      DisplayName="ExpiresDate" Name="ExpiresDate"
      Type="DateTime" Required="False"
      UnlimitedLengthInDocumentLibrary="FALSE"/>


  <!-- Parent ContentType: Element (0x01) -->
  <ContentType ID="0x0100b48c62c42879472aa8f1e1afc4dba7ce"
               Name="GroupsList - ContentTypeGroups"               
               Group="Custom Content Types"
               Description="My Content Type"
               Inherits="false"
               Version="0">
      <FieldRefs>
        <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />

      <FieldRef ID="{51CC6776-F855-48d5-A4EC-B7CE11CE2324}" Name="ExpiresDate" Required="FALSE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" />
      </FieldRefs>
  </ContentType>
</Elements>

Now I wanted to read out the fields content via powershell:

$site = New-Object Microsoft.SharePoint.SPSite($GroupListURL)
$web = $site.OpenWeb()
$list = $web.Lists[$GroupListName]
$items = $list.Items
$listitem = $list.Items.GetItemByID($ItemID)
$ExpiresDate = $listitem["ExpiresDate"]

But I'm only get Null for ExpiresDate. If I set inheritation to true I get ExpiresDates Value but the TitleField is still visible.

Does anyone know why?

1
  • What do you get for $listitem.ContentTypeId? In other words, are you sure the list item is using your custom content type? Commented May 31, 2012 at 17:52

2 Answers 2

1

You content type inherits from system/item according to the content type id:

0x0100b48c62c42879472aa8f1e1afc4dba7ce

See http://msdn.microsoft.com/en-us/library/aa543822.aspx

Title is a required to be a part of any content type that inherits from Item.

I'm not sure why you want to delete the Title field. If you want to inherit from the Item content type, can you just set a default value on the Title field and hide it?

2
  • Thanks! But how to hide the title field in visual studio?
    – MOI
    Commented May 31, 2012 at 5:52
  • Include a FieldRef to it and set it's Hidden property to TRUE
    – James Love
    Commented Jun 2, 2012 at 17:08
1

As Doug mention don't delete the Title field. The better way is to set it optional and then hide it. You will also have some drawback when you hide the title field. For example you will lose the dropdown menu because it is attached to the title field.

You can hide fields form a form by using powershell. I wrote about this in the following blog post. http://www.n8d.at/blog/sharepoint-2010/hide-fields-from-lists-and-content-types/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.