Count the Number of Users in Tables
Contents
Overview
This article introduces how to count the number of specific users in a table.
Sample Image
An event is triggered when the Save button is clicked. The number of each user listed in the User selection field of the table is aggregated. The results are then inserted into Number fields. The sample in this article counts two types of users, and inserts the aggregated result into two different Number fields.
Prepare the App
Create an App with the following fields and settings.
Field Type | Field Name | Field Code | Notes |
---|---|---|---|
Table | User Table | TableField | See the table below for the fields to place inside. |
Number | User 1 Count | UserCountField1 | |
Number | User 2 Count | UserCountField2 |
Set the following fields and settings for the User Table table.
Field Type | Field Name | Field Code | Notes |
---|---|---|---|
Date | Date | date | |
User selection | Staff | user_selection |
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, filling in the User selection fields with users defined in the code. After saving the record, the number of specific users listed in the table should be inserted into the designated Number fields.