Skip to content

Instantly share code, notes, and snippets.

@vaderj
Last active June 12, 2018 16:54
Show Gist options
  • Save vaderj/15fb69b2937e3dd388d20e04f61be3f4 to your computer and use it in GitHub Desktop.
Save vaderj/15fb69b2937e3dd388d20e04f61be3f4 to your computer and use it in GitHub Desktop.
Add a new property to the SPWeb property bag in JSOM #Javascript #SharePoint #SOAP
function AddWebSiteProperties(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
oWebsite = clientContext.get_web();
alert(oWebsite);
clientContext.load(oWebsite);
alert("Load");
var props = oWebsite.get_allProperties();
props.set_item("Myproperty", "PropertyValue");
oWebsite.update();
clientContext.load(oWebsite);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded2),
Function.createDelegate(this, this.onQueryFailed2)
);
}
function onQuerySucceeded2(sender, args) {
alert("Success"); }
function onQueryFailed2(sender, args) {
alert("Failed");
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment