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 ?

1
  • 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. Commented Jun 30, 2019 at 9:21

1 Answer 1

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.