Last active
June 12, 2018 16:54
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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