December 12, 2011 12:32 PM

Q: I need to change a property bag value that appears at the SharePoint list level. I understand that the SharePoint list doesn’t contain a Properties collection. How could this have happened, and how can I change the value for an existing list?

SharePoint Pro
InstantDoc ID #141581
Rating: (0)

Problem: The SPList object doesn’t contain a property bag. However, a property was assigned indirectly to a list through the RootFolder object through an Elements.xml file in a list instance.

Specifically, the elements XML of a list named List01 could contain the following property named property01 with a value of value01 inside of the Elements element:

<PropertyBag Url="List01" ParentType="Folder" RootWebOnly="FALSE"

xmlns="http://schemas.microsoft.com/sharepoint/">

<Property Name="property01" Value="value01" Type="string" />

</PropertyBag>

You need to assign a different value to value01 using Windows PowerShell.

Solution: From the SharePoint 2010 Management Shell, get the RootFolder of the list and update the property:

# get the web01 web containing list01 in the example contoso web

application

$web = get-spweb -site "http://www.contoso.com/sites/web01"

# get the list, list01

$list = $web.Lists["List01"]

# get the RootFolder of the list

$root = $list.RootFolder

# set the value of property property01 to value02

$root.Properties.property01 = "value02"

# save the rootfolder change

$root.Update()

# dispose of the web

$web.Dispose() 

Here’s a related problem and solution:

Problem: You need to add a property key and value to a list, but a list doesn't contain a property bag.

Solution: Assign a new key value pair to the rootfolder of the list:

# get the web01 web containing list01 in the example contoso web

application

$web = get-spweb -site "http://www.contoso.com/sites/web01"

# get the list, list01

$list = $web.Lists["List01"]

# get the RootFolder of the list

$root = $list.RootFolder

# create a new key value pair and assign it to the root folder

$root.Properties.Add("property04", "value04")

# save the change

$root.Update()

# dispose of the web

$web.Dispose() 

To see more SharePoint FAQs, go to the SharePoint Pro FAQ page.

Related Content:

ARTICLE TOOLS

   
Comments
  • Caroline Marwitz
    4 months ago
    Jan 20, 2012

    I think I got them. Let me know if I missed some.

  • EthanW
    4 months ago
    Jan 15, 2012

    Right you are, Randy. I'll ask Penton to update the article to change $root.Properties.Update() to $root.Update().

    Ethan

  • Randy Williams
    5 months ago
    Dec 22, 2011

    This is a useful tip, but you cannot call the Update method on the properties hash table. Instead, just call Update on the RootFolder class of SPList. For example, $root.Update()

You must log on before posting a comment.

Are you a new visitor? Register Here
   
   

Dan Holme's Viewpoint on SharePoint Blog

Office 365 Plan for Pain

With cloud services, even Office 365, what you don’t know about your cloud service can hurt you,...

SharePoint News and Products

Let SharePoint Be SharePoint: Making Social Collaboration Secure

Hesitant about unleashing SharePoint's social features? SharePoint security vendors aim to help....

Dan Holme's Viewpoint on SharePoint Blog

Microsoft SkyDrive Updates in the News

Microsoft's cloud storage, sharing, and collaboration platform for Windows Live is updated,...