Limitation of getting record information from Apps
When working with Kintone customizations, there are many scenarios where you would need to retrieve information of every record in your app.
When doing this, it's important to understand what methods you can take, and what the limitations are.
Using the Record List Event (app.record.index.show)
Kintone has a record list event.
This event runs when the record list is displayed, and provides the user with an event object containing information of all of the records in the current record list.
The number of records that are given back here though are limited to the number of records that are displayed on the page. Kintone shows from 20 to 100 records in the record list page (this can be tweaked on an option listed on the record list page), meaning that you will only be able to get information of a maximum of 100 records in the event object. This becomes an issue obviously, when you need to deal with more than 100 records.
Using the Get Records API
By default, this API retrieves up to 100 records, but by setting the "limit" option in the query parameter, this limit can be raised to a maximum of 500 records. We still have the same issue here though - what do we do when we have over 500 records in our app?
How to get all records from an App
The answer to this, is to use the Get Records API recursively, using promises.
Recursive functions are functions that make a call to itself - basically meaning that we can call the Get Records API, and once we hit the limit of the records we can retrieve, we can make the function call itself again to retrieve even more records. This will continue until we have retrieved every record from the app.
Promises, which may be a harder concept to understand, allow the functions to be called one after the other. You may think that placing the Get Records API in a standard for loop would do the job, but since the Get Records API is an asynchronous operation, the loop tends to end before we even get our first set of results back. What promises do, is that it waits for the results of the first Get Records API to come back before sending its request for the second Get Records API, and the same for the third, forth etc.
This code will give back information of all records of an app, and display it all in your developer console of your browser.
You can try out using this code right now by opening the record list of your Kintone app, and copy and pasting the code above.
This code will come in handy for many types of Kintone customizations - for example, you can use it in conjunction with Kintone's "Customized View" (a feature that displays custom HTML on the record list view) to display more than 100 records.