Skip to content

Instantly share code, notes, and snippets.

@islaytitans
Created July 29, 2015 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islaytitans/356c7a342fef40e2b71d to your computer and use it in GitHub Desktop.
Save islaytitans/356c7a342fef40e2b71d to your computer and use it in GitHub Desktop.
Sitecore Hackathon UpdateItem
UpdateItem: function () {
var itemService = new entityService({
url: "/sitecore/api/ssc/DevToolKit-Controllers/SitecoreItem"
});
var querystring = this.GetQueryString();
var itemid = querystring["itemid"];
var message = this.messagePanel;
var fieldsToReset = this.GetItemsToReset();
var result = itemService.fetchEntity(itemid).execute().then(function (item) {
for (var i = 0; i < item.Fields.underlying.length; i++) {
var field = item.Fields.underlying[i];
if ($.inArray(field.Name, fieldsToReset) != -1) {
field.RevertToStandardValue = true;
}
}
item.save().then(function (savedItem) {
message.addMessage("notification", { text: "Item updated successfully", actions: [], closable: true, temporary: true });
}).done(this.GetFields());
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment