Count the Number of Rows in Tables
Contents
Overview
This article introduces how to count the number of rows in a table of a Kintone App, and insert the result into a Number field.
Sample Image
An event is triggered when the Save button is clicked. The number of rows are counted, and are inserted into a Number field.
Prepare the App
Create an App with the following fields and settings.
Field Type | Field Name | Field Code | Notes |
---|---|---|---|
Text | Test Name | testname | |
Table | Test Results | mytable | See the table below for the fields to place inside. |
Number | Number of rows in table | number_of_rows | |
Calculated | Average Result | avr_result | Set the following formula
|
Set the following fields and settings for the Test Results table.
Field Type | Field Name | Field Code | Notes |
---|---|---|---|
Text | Name | name | |
Number | Test Result | testresult |
Sample Code
Prepare the following JavaScript code in a text editor and navigate to the Kintone App's settings. Upload the file into the Upload JavaScript for PC option of the JavaScript and CSS Customization settings .
|
|
After saving the settings and clicking on Update App, create a new record. Add several rows in the table and fill them with data. After saving the record, the number of rows should be inserted into the Number field.