(End-of-Support) Add Records with the Command Line Tool (v0)
Overview
This article introduces how to use the Kintone Command Line Tool v0 (cli-kintone v0) to add record data into a Kintone App.
Attention
As of October 31st 2023, support for cli-kintone v0 has ended. For the latest features and security support it is highly recommended to upgrade to cli-kintone v1 .
For more information, refer to the End of Support Notice for cli-kintone v0 .
This tutorial uses the Customer Database available in the
Kintone Marketplace
.
Add Records
STEP 1: Prepare a CSV file
Prepare a CSV file that will be used to add record data to the Kintone App. It is not necessary to list every field in the App in the CSV file - the fields can be limited to those to add data to, as shown below:
|
|
Make sure to write the field code in the first row, and not the field name. Save the data as customers.csv.
STEP 2: Add records by specifying the CSV file
In addition to the authentication option, use the -f option to specify the file to import.
If customers.csv is saved in the same location as the cli-kintone executable file:
|
|
If the file path of customers.csv is specified:
|
|
If the file path of customers.csv is specified and imported from a specified line:
|
|
Add Records After Deleting Records
Add records after deleting all records
Use the -f and -D options to delete all records before adding new records. If no query is specified, all records in the App will be deleted before records are added.
|
|
Add records after deleting filtered records
Specified records can be selected to be deleted before adding new records. To specify those records, filter them using the -q option. Refer to the Query string article for information on how to write queries. In the example below, the 5 latest records that have "Krispy" as the contact name are deleted before the new records are added:
|
|
Add Records with Table Data
In this example, the Expense Report App available in the
Kintone Marketplace
is used.
STEP 1: Create a CSV file containing table data
To add records that include table data, add an * symbol in the first column of the row that contains the field codes. Also add the * symbol to each row that contains the first table data row of tables in each record. To avoid making mistakes, use a CSV file exported by cli-kintone as reference.
|
|
Save the contents above as tabledata.csv.
STEP 2: Add records by specifying the CSV file
Use the -f option to specify the CSV file to add records with table data.
|
|
The contents of the CSV file looks like the below when opened in Excel.
These are the screenshots of the three records that have data added to them. The data in the colored rectangles above match the data in the colored rectangles below.
CSV data for Check box and Multi-choice Fields
Check box fields and Multi-choice fields are fields that can hold multiple values. A carriage return must be used to separate the multiple values for these fields. If the data is viewed in Excel, the multiple values can be seen on several lines inside one cell. When editing on excel, use the Alt + Enter shortcut in a cell for a carriage return.
The same goes for the tables. If the table contains these fields, separate the multiple values within these fields with carriage returns.
Example CSV data
The two records in the above image can be represented with the following CSV:
|
|
In Excel, this looks like the below:
Example CSV data for tables
The two records in the above images can be represented with the following CSV:
|
|
In Excel, this looks like the below:
Debugging Errors
If any errors occur, check the logs that are outputted into the console.
|
|
The problem can also be identified by checking the requests on the
Audit Log
in the System Administration page.
Click the gear icon on the upper right menu of Kintone, and go to User & System Administration -> Audit Logs -> View & Download.
From the Audit Log list, it is possible to see what record operations were performed. Their success/failure as well as the details of each operation can be seen by clicking the i mark on the left side of the table.
Looking at this information allows the user to see if requests from cli-kintone are successfully reaching their Kintone environment. Use this information to find causes of any particular issues and debug them.