sharepointsplistitemsplist

Set Default Field Value Based on Site Property


I am looking for a way to set a list field default value to a property that I have programmatically set on the site where the list resides.

Essentially every item in the list will have the same value which will be hidden from the normal user view. Down stream, I am using a content query web part to pull that field so I can group on it.

I am using SP2013.

Thanks for the help


Solution

  • With Site Properties you mean the SPSite.RootWeb.AllProperties property bag which you have filled with some custom property?

    Assuming that is what you are talking about, there are unfortunately no standard ways to work with property bags - besides programming that is.

    You said you want to set a default value on a list field for each list item. This sounds like an event receiver! You can choose to have it fire on item updating and/or item created for all your items and always set the hidden field on the item with the value from the site properties.