Trying to take my Sunday a bit easy but why not just put in a bit effort to make others lives a bit easier?! If you need to see some JSOM in action for reading property bag values, or just want to see what those darn values are heres a quick script to run in your browser developer console. Outputs all property bag values from the current SharePoint web. Keep in mind that properties are web-scoped.

function ListAllProperties()
{
    var ctx = new SP.ClientContext.get_current();
    var web = ctx.get_web()
    this.propertyBag =  web.get_allProperties();
    ctx.load(web);
    ctx.load(this.propertyBag);
    ctx.executeQueryAsync(Function.createDelegate(this, propertiesLoaded), null);
}   

function propertiesLoaded() 
{
    var myPropBag = this.propertyBag;
    var myPropValues = propertyBag.get_fieldValues();	

	console.log(myPropValues);
	
	for (var key in myPropValues){
		if(!key.startsWith("__"))
			{
				console.log(key + ": " + myPropValues[key])
			}
	}

}

function pbKeys(obj)
{
    var keys = [];
    for(var key in obj)
    {
        if(obj.hasOwnProperty(key) && !key.startsWith("__"))
            keys.push(key.toLowerCase());
    }

    return keys.sort();
}

ListAllProperties();

Stay frosty SP devs.

No Comments

There are no comments related to this article.