0

for 2 days i'm going nuts with the property bag in SP 2013 using javascript and CSOM. I was following this post example property bag about writing and reading property bag keys in SP 2013 using CSOM ... and it works great! However can somebody tell how can I delete/update a key ? So in that example, how you can delete the key using CSOM?

Another question: how can I achieve the same (CRUD) using the new REST API in SP 2013 using jQuery? I'm talking about calling the REST endpoint: http://site_here/_api/web/AllProperties ?

David Dury
  • 5,537
  • 12
  • 56
  • 94

2 Answers2

0

You can update key value with set_item() method.

There is code snippet:

var clientContext = SP.ClientContext.get_current();
var oWebsite = clientContext.get_web();
clientContext.load(oWebsite);
var webProps = oWebsite.get_allProperties();
clientContext.load(webProps);
clientContext.executeQueryAsync(successHandler, errorHandler);

function successHandler() {
    var client = webProps.get_fieldValues().Client;
    var newClient = "newClient";
    webProps.set_item("Client", newClient);
}

I think it must be possible in REST, as CSOM is just wrapper over REST. You can get request to http://yourServer.com/_vti_bin/client.svc/ProcessQuery with Fiddler or browser developer tools.

0

It's not the desired approach. Some endpoints are read only while others are read/write: See the table at https://msdn.microsoft.com/EN-US/library/office/dn499819.aspx#bk_WebProperties. I would use the JSOM API to update values when they are not read/write as a rest endpoint.

Nelson
  • 55
  • 2
  • 8