function updateEntity(entityName, id, entity ) {
var url = oDataUrl + "/" + entityName + "Set(guid'" + id + "')";
entityData = window.JSON.stringify(entity);
return $.ajax({
type: "POST",
contentType: "application/json;charset=utf-8",
datatype: "json",
data: entityData,
url: url,
beforeSend: function (x) {
x.setRequestHeader("Accept", "application/json");
x.setRequestHeader("X-HTTP-Method", "MERGE")
},
});
}
entityName is the logical entity name.id is the Id of the record that we want to update
entity is a object that contains that values that need changing.
e.g.:
account = {};
account.Name = "New Name";
oDataUrl is the Url of the OData endpoint for your organization
No comments:
Post a Comment