2

I'm using REST API for updating the SharePoint list item (Counter). In my code on form load I'm fetching the count from list and increment to 1 & on submit button click I'm updating the value of count. Till here I have achieved.

Problem arises , If two users submit the form at the same time, then counter value is incremented by 1 instead to 2 in the list.

Checked with etags . But I found that during post if etag doesn't match with get request etag then error will be thrown.

Is there way to achieve this functionality using REST API also incrementing the counter properly , if more than 3-4 users submit the form ?

  • Once the eTag value does not match and it throws the error, get a new eTag and call the update function inside the error function. – Ravi Jun 30 at 9:21
1

Before update the list item using REST API, you need get the etag using REST API, and the the etag value in "IF-MATCH" of the POST headers when update the list item. If the code throw the error, we can alert the user refresh the page or wait some time, then resumbit the form.

The following articles for your reference:

Using ETags in SharePoint REST Calls to Manage Concurrency Control

Writing data by using the REST interface

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.