Updating a content type with new column, but need to add the default value to existing items
-
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 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?
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.
-
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.
yeah, all new items do, but I'm talking about items that were in the list before the new column was added
-
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?
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.