1

I have a requirement to update the schema files of a list template which modifies the options available to the fields.

But, when I am updating the schema file the options for the already defined lists is not updated.

So, how to update the options for all the lists defined from this list template.

Thanks in advance!

2 Answers 2

2

WHat do you mean by "options available to fields". Do you mean you want to add extra Choices to a Choice field used in the list? If so, create a feature with a feature receiver and access the SPList, the the available fields in the list, get the field you want to update, Cast it to a SPFieldChoice, add the new values to the Choices collection and call the field's Update method, then the SPList's Update method.

If the field in question is a field available as a site column in the entire site, get the RootWeb's Fields collection, find your field and perform the same actions to add choice values. This time, call the Field's Update mathod with true as parameter, so the changes will get pushed down to any list using the field. Then call the RootWeb's Update method.

2
  • Many Thanks Colin, this is exactly what i required 'edit choices to a Choice field used in the list'.
    – goso
    Oct 20, 2011 at 8:30
  • C-Marius and Colin, your answers were very helpful!
    – goso
    Oct 20, 2011 at 8:32
2

Once the list (or webs for that matter) is created there is no more link between new versions of the definition. You should envision configuring those via code.

4
  • Thanks C-Marius, But, I have to allow user a set of options for their field values. How do you recommend I can provide user those options on editing already existing list items?
    – goso
    Oct 19, 2011 at 18:35
  • Are you refering to options such as Default values, Calculated formula as such? Could you be more specific please, give me an example? Oct 19, 2011 at 20:46
  • C-Marius, I require to remove the already existing Choices to a Choice field used in the list and add new choices for the field?
    – goso
    Oct 20, 2011 at 8:28
  • Colin's answer is absolutely valid! If you do deploy your fields (& lists) via a Features (probably along with content types), take into consideration also the Context (Scope) of your deployment. Oct 20, 2011 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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