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 want to know how to change Required Property on site column when it is consumed in a list definition.

like i have deployed a site column

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <Field ID ="{aae098f7-c7b0-4236-a8ec-9908e9acf2a0}" 
         Name="ABC" 
         Type="Lookup" 
         UnlimitedLengthInDocumentLibrary="TRUE" 
         DisplayName=" " 
         List="Lists/Directory" 
         ShowField="Title" 
         Required="FALSE"
         Group="Custom"
         Overwrite="TRUE"
         OverwriteInChildScopes="TRUE"
         Description=""
         />
</Elements>

i have declared it Required="FALSE" for a list Definition but when i reuse this column in another list definition i want to set it Mandatory, so in the content type that i have defined in the list definition (schema.xml) i made it Required="TRUE" as:

 <ContentTypes>
      <ContentType ID="0x01001CC809EB1E174539A92FDA8EEA9CABFD"
                   Name="xyz"
                   Group="custom CT"
                   Description=""
                   Inherits="FALSE"
                   Version="0">
        <FieldRefs>
          <FieldRef ID ="{97BA70AA-BC2C-496C-8565-56F99ABF91A4}" Name="R"/>
          <FieldRef ID="{61389c59-cf0e-45ab-a6b4-30dca223f47c}" Name="C"/>
          <FieldRef ID="{aae098f7-c7b0-4236-a8ec-9908e9acf2a0}" Name="ABC"/>
        </FieldRefs>
      </ContentType>
    </ContentTypes>
    <Fields>
      <Field ID ="{97BA70AA-BC2C-496C-8565-56F99ABF91A4}" Name="R" Type="Lookup" DisplayName="$Resources:Region" List="Lists/Regions" ShowField="Title" Required="TRUE" />
      <Field ID="{61389c59-cf0e-45ab-a6b4-30dca223f47c}" Name="C" Type="Lookup" DisplayName="$Resources:Country"   List="Lists/Countries" ShowField="Title" Required="TRUE"></Field>
      <Field ID ="{aae098f7-c7b0-4236-a8ec-9908e9acf2a0}" Name="ABC" Type="Lookup" DisplayName="$Resources:ABC" List="Lists/Brands" ShowField="Title" Required="TRUE" />
    </Fields>

but it will remain not required . is there any way to make it required for one list , and not required for other list .

thankx in advance

share|improve this question

migrated from stackoverflow.com Sep 15 '11 at 14:40

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

What you are doing (changing the XML schema of a field or content type while it is in use) is unsupported. ANY changes to fields done AFTER deployment and usage should be done using code (or in SP2010 using FeatureUpgradeActions! This is because the schema is saved (ghosted) to the content database.

Furthermore, it is not possible to have the same schema behave differently for 2 lists (i.e. field required in list A and not required in list B). A Content type is list agnostic, meaning it knows nothing about the list using it. The content type is actually "copied" to the list (notice the extra GUID in the ctype id when editing from list settings?). Any changes in behavior per list means creating either separate content types, or changing the field behavior for the content type in the list (settings) itself.

share|improve this answer
add comment

What you want to do is possible. Try setting Required in the Content Type:

  <ContentType ID="0x01001CC809EB1E174539A92FDA8EEA9CABFD"
               Name="xyz"
               Group="custom CT"
               Description=""
               Inherits="FALSE"
               Version="0">
    <FieldRefs>
      <FieldRef ID ="{97BA70AA-BC2C-496C-8565-56F99ABF91A4}" Name="R" Required="TRUE"/>
      <FieldRef ID="{61389c59-cf0e-45ab-a6b4-30dca223f47c}" Name="C" Required="TRUE"/>
      <FieldRef ID="{aae098f7-c7b0-4236-a8ec-9908e9acf2a0}" Name="ABC" Required="TRUE"/>
    </FieldRefs>
  </ContentType>
share|improve this answer
    
no. its not working ,.... same output .the column is still not mandatory . –  Umbrella Corporation Sep 23 '11 at 7:35
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.