Count table rows

This sample code counts the number of rows you have in your table, and places that number in a given field, when you save your record data.

Sample Image


Sample Code

(function() {
    "use strict";
    //Set events to run when the save button is clicked on the record create or edit page["app.record.create.submit","app.record.edit.submit"], function(eventobj) {
        //Count the number of rows in the table
        var num_of_rows = eventobj.record.TABLEDATA.value.length;
        //Set a new value in a field, listed in the event object       
        eventobj.record.ROWCOUNT.value = num_of_rows;
        //Return the event object, so that kintone will use this new data
        return eventobj;


TABLEDATA is the field code set on the table.
ROWCOUNT is the field code set on the "Number of rows in table" field.


Refer to this page, on how to add scripts to your app.

Was this article helpful?
0 out of 0 found this helpful
Please sign in to leave a comment.