1

Issue

Using REST, I populate a list onto a page. I want the page to refresh the list without refreshing the page whenever a new item is added to the list.

Current Shoddy Solution

I have 2 GET requests. 1 is to populate the list onto the page, the other is to check the ID of the TOP item. Request 2 runs every 5 sec using setInterval(). I then compare the IDs of the newest item and the last one posted on my page (embedded the ID into the ID tag and then retrieved). Using an IF, if the newest added item ID is not equal to the latest item on the page, I run GET request 1 again to populate the new data on the page.

This is working well from the end user's perspective and doesn't seem to be taxing resources too much but, I feel like running a GET request, even if it's lite, pulling the only top item and only the ID column, is still a GET request every 5 sec.

Is this acceptable and I'm worrying too much? Are there better ways to check if a new item has been added?

2 Answers 2

1

depends on how many folks are using the list at the same time. Also i think 5 seconds is way to much. You are already thinking about only the ID, so you wont do a full transfer and ID is also indexed, but still... 30 seconds will be plenty of time.

If you need more real time feedback, replace the human processing the result and replace him with a webhook or workflow ;) And no, i rather have someone who worries about this than someone who does not think about the fact that he is using SHARED ressources

3
  • Thanks for the feedback. The SPA is basically a Team Messenger type app. I may be able to back it up to 10 sec but, 30 may be a little too long. You didn't have the context so I can see why 30 sec was your suggestion from a share resources perspective. There's only 6 people on their team luckily, so only that many at once at peak usage.
    – AtariPixel
    Mar 22, 2018 at 18:22
  • :( No support for webhooks in SP2013 on-prem.
    – AtariPixel
    Mar 22, 2018 at 19:06
  • i was about to mention that we do have some chat capable apps esp for Teams... ;) But you mentioned 2013... Mar 22, 2018 at 19:11
1

Subscribing to an email alert to be notified when new items are added to the list may be the easiest way to go.

Seeing the newest items by default relates to sorting your list by the Created date column in descending order.

To make a web part or list view automatically refresh, go to the view > modify the page > edit the web part and expand and check the boxes shown below. This makes the list refresh every minute without having to re-load the page.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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