I can successfully create a sub-site from a custom template using the REST api and jQuery from MSDN example. But is there a way to set custom propertybag key values in the process?
For example, the site template has the custom propertybag keys of myRegion, myGroup, myType, myDate that I would like to be dynamic based on entries in form fields. Can I set these values when the ajax call is made? If I try to set them as parameters I get the error...
"The property 'myRegion' does not exist on type 'SP.WebInfoCreationInformation'. Make sure to only use property names that are defined by the type."
That tells me that SP.WebInfoCreationInformation is looking for specific key/value pairs but I can't find a listing anywhere.
You can try using CSOM. Something like this -
function setWebProperties() {
var execOperation = function () {
var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
this.properties = web.get_allProperties();
this.properties.set_item("<propKey>", "<propValue>");
ctx.load(web);
web.update();
ctx.executeQueryAsync(function fSuccess(data) {
alert(this.properties.get_item("<propKey>"));
}, function fError(sender, args) {
alert("Error - " + args.get_message());
});
}
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', execOperation);
}