# Hitting the 10 transactions per second limit - please help

**URL:** <https://forums.knack.com/t/hitting-the-10-transactions-per-second-limit-please-help/7231>\
**Category:** API & Custom Code\
**Created:** [December 12, 2017, 7:14pm UTC](https://forums.knack.com/t/hitting-the-10-transactions-per-second-limit-please-help/7231 "2017-12-12T19:14:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheBug71303](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@TheBug71303](https://forums.knack.com/u/TheBug71303)\
**Post date:** [December 12, 2017, 7:14pm UTC](https://forums.knack.com/t/hitting-the-10-transactions-per-second-limit-please-help/7231/1 "2017-12-12T19:14:09Z")

</div>

I have a table on a page with 25 checklist items - it's quite time consuming to change them one-by-one via inline editing. So I want to provide users with a button to update them all at once. I have the code in place, it works - but I'm hitting the 10 per second limit every time - and then the code stops.

I would really appreciate a helping hand to get some timeout or response check built into it so it works.

The code:

//Button to update all checklist items  
var LAST\_UPDATED\_FIELD\_ID = "field\_46";  
var es\_resource\_records = {};  
var counter = 0;  
$(document).on('knack-records-render.view\_59', function(event, view, records) {  
   
 $("#view\_59").append("\<button id='button\_mark\_reviewed'style='padding: 0 10px; line-height: 22px;' class='kn-button-menu'\>Check alle\</button\>");

es\_resource\_records = {};  
 es\_resource\_records = records;  
   
 $("#button\_mark\_reviewed").click(function() {   
 es\_last\_updated();  
 });   
   
});

function es\_last\_updated() {  
   
 Knack.showSpinner();  
   
 var records\_updated = 0;  
 for (var x = 0; x \< es\_resource\_records.length; x++) {  
 es\_update\_field(es\_resource\_records[x]['id'], LAST\_UPDATED\_FIELD\_ID, "True", function() {  
 if (++records\_updated == es\_resource\_records.length) {  
 location.reload();  
 Knack.hideSpinner();  
 }  
 });  
 }  
}

function es\_update\_field(record, field, value, callback) {  
 var data = {};  
 data[field] = value;  
   
 $.ajax({  
 url: "[https://api.knackhq.com/v1/objects/object\_6/records/"+record](https://api.knackhq.com/v1/objects/object_6/records/%22+record),  
 type: "PUT",  
 headers: {  
 "X-Knack-Application-Id": "My key",   
 "X-Knack-REST-API-Key": "My key"  
 },  
 data: data,  
 success: function(response) {  
 console.log('Checks updated!!!');  
 }  
 });  
 }

---

<div class="post-metadata">

**Author:** ![TheBug71303](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@TheBug71303](https://forums.knack.com/u/TheBug71303)\
**Post date:** [December 14, 2017, 10:07pm UTC](https://forums.knack.com/t/hitting-the-10-transactions-per-second-limit-please-help/7231/2 "2017-12-14T22:07:45Z")

</div>

Thanks Keith.

I will experiment with your suggestion. Appreciate it.

---

<div class="post-metadata">

**Author:** ![KeithSterl25609](https://avatars.discourse-cdn.com/v4/letter/k/ee59a6/32.png) [@KeithSterl25609](https://forums.knack.com/u/KeithSterl25609)\
**Post date:** [December 13, 2017, 10:18pm UTC](https://forums.knack.com/t/hitting-the-10-transactions-per-second-limit-please-help/7231/3 "2017-12-13T22:18:34Z")

</div>

This should work....

 

 

function es\_update\_field(record, field, value, callback) {

 var data = {};  
 data[field] = value;

 $.ajax({  
 url: "[https://api.knackhq.com/v1/objects/object\_6/records/"+record](https://api.knackhq.com/v1/objects/object_6/records/%22+record),  
 type: "PUT",  
 headers: {  
 "X-Knack-Application-Id": "My key",   
 "X-Knack-REST-API-Key": "My key"  
 },  
 data: data,  
 success: function(response) {  
 console.log('Checks updated!!!');  
 }  
 })

 // catch the rate limit error and recall the function  
 .then(null, response =\> {  
 if (response.status == 429) {  
 return es\_update\_field(record, field, value, callback);  
 }  
 });

}
