Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the following ContentType Elements.xml file in a visual studio project. I need the ArticleStartDate to be mandatory/required. When the deployment happens the field is not required. I can't understand why this is happening.

Can anyone help please?

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Field ID="{DF8D882A-8C54-4E8A-BB60-8D49D0B2E116}"
     Name="Summary"
     DisplayName="Summary"
     RichText="TRUE"
     RichTextMode="ThemeHtml"
     Type="HTML"
     Hidden="FALSE">
  </Field>
  <!-- Parent ContentType: Article Page (0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D) -->
  <ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D008a292b3f7b4946538115a7ca60abbe87"
               Name="Toyota News Article"
               Group="Toyota"
               Description="Toyota News Article"
               Inherits="TRUE"
               Overwrite="TRUE"
               Version="0">
    <FieldRefs>
        <!-- ... -->
        <FieldRef ID="{71316CEA-40A0-49f3-8659-F0CEFDBDBD4F}" Name="ArticleStartDate" Required="TRUE" />
    </FieldRefs>
  </ContentType>
</Elements>
share|improve this question
add comment

2 Answers

Did you try to use Required="True" in both Field and FieldRef element also? Try the example below:

Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <Field ID="{DF8D882A-8C54-4E8A-BB60-8D49D0B2E116}"
     Name="Summary"
     DisplayName="Summary"
     RichText="TRUE"
     Required="True"
     RichTextMode="ThemeHtml"
     Type="HTML"
     Hidden="FALSE">
  </Field>
  <!-- Parent ContentType: Article Page (0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D) -->
  <ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D008a292b3f7b4946538115a7ca60abbe87"
               Name="Toyota News Article"
               Group="Toyota"
               Description="Toyota News Article"
               Inherits="TRUE"
               Overwrite="TRUE"
               Version="0">
    <FieldRefs>
        <!-- ... -->
        <FieldRef ID="{71316CEA-40A0-49f3-8659-F0CEFDBDBD4F}" Name="ArticleStartDate" Required="TRUE" />
    </FieldRefs>
  </ContentType>
</Elements>
share|improve this answer
add comment

This content type is associated with a list obviously.

When you add a Content Type to the list definition, the columns are not added automatically; you have to declare them in the list definition also. Go to the Fields section of your schema.xml and append your columns:

Don't forget to add your columns to any views as well.

Also, keep in mind that the required = true only works at the client level. The database will always allow NULLS for custom fields.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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