I am implementing a custom solution on SharePoint Online, and, I want to add 1 (increment) to the current value of a specific field number (TotalViews) using rest API.
Here is my code:
function UpdateViewsinHow(param)
{
var data = {
__metadata: { 'type': 'SP.Data.HowListListItem' },
TotalViews : TotalViews+1 // here how to add 1 to current Totalviews
};
$.ajax({
url: siteUrl + "/_api/web/lists/getbytitle('HowList')/items("+param+")",
method: "PATCH",
data: JSON.stringify(data),
headers: {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"IF-MATCH": "*",
"X-HTTPS-Method": "MERGE"
},
success: function (data) {
// confirm
},
error: function (error) {
alert("Error: " + JSON.stringify(error));
}
});
}
Any advice to achieve this step?