Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. SharePoint
  4. Updating a content type with new column, but need to add the default value to existing items

Updating a content type with new column, but need to add the default value to existing items

Scheduled Pinned Locked Moved SharePoint
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aptiva Dave
    wrote on last edited by
    #1

    I have a content type that I am needing to add a new column to. This new column is a boolean field and by default it is set to False. Now, I already have alot of items in the existing list, so each of these will need to be updated as well with the default value of the field, but how would I do that? Do I do that in the Event Receiver of the Feature object? And under which method would I do that under: FeatureActivated or FeatureUpgrading?

    I 2 Replies Last reply
    0
    • A Aptiva Dave

      I have a content type that I am needing to add a new column to. This new column is a boolean field and by default it is set to False. Now, I already have alot of items in the existing list, so each of these will need to be updated as well with the default value of the field, but how would I do that? Do I do that in the Event Receiver of the Feature object? And under which method would I do that under: FeatureActivated or FeatureUpgrading?

      I Offline
      I Offline
      Ingo
      wrote on last edited by
      #2

      Aptiva Dave wrote:

      This new column is a boolean field and by default it is set to False.

      Every column can have a default value, so if you set "false" as default, every item should have that by default without programming. Yep, I was wrong here.

      ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

      A 1 Reply Last reply
      0
      • I Ingo

        Aptiva Dave wrote:

        This new column is a boolean field and by default it is set to False.

        Every column can have a default value, so if you set "false" as default, every item should have that by default without programming. Yep, I was wrong here.

        ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

        A Offline
        A Offline
        Aptiva Dave
        wrote on last edited by
        #3

        yeah, all new items do, but I'm talking about items that were in the list before the new column was added

        1 Reply Last reply
        0
        • A Aptiva Dave

          I have a content type that I am needing to add a new column to. This new column is a boolean field and by default it is set to False. Now, I already have alot of items in the existing list, so each of these will need to be updated as well with the default value of the field, but how would I do that? Do I do that in the Event Receiver of the Feature object? And under which method would I do that under: FeatureActivated or FeatureUpgrading?

          I Offline
          I Offline
          Ingo
          wrote on last edited by
          #4

          Ok, sorry I was a little bit to optimistic. The default-value isn't updated automatically. So there is a little bit programming needed. :doh: The way I would do it: Build a normal .Net Windows-Applikation, open the List go through the SPItems and change the value of the specific field.

          ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups