To Start Off
This tutorial will guide you on how to retrieve values from a record in your kintone record details page.
Step 1. Retrieve Record ID value
We will first retrieve the Record ID of the current record initiated by a button click.
Record IDs are the key IDs for each record in an app, that starts from 1. We will use the function of kintone.app.record.getId() to retrieve the Record ID. Check here for more details of the API.
Please note that this function is only for the Desktop, not for the Smartphone. Below is a sample code for retrieving and displaying the Record ID.
A button should appear on the record details page. Click it to retrieve and display the record ID of the record you are viewing.
Step 2. Retrieve record value
The function we will use here will be kintone.app.record.get(). For Smartphones, use kintone.mobile.app.record.get() instead.
The returned value will be in a JSON format, and null will be returned in case of errors.
A sample code can be written as follows:
You will need to replace field_code with the field code of your field that you want to retrieve the value from. Field codes can be checked and updated from the app settings menu.
Navigate through to Edit Form > (Hover over a field already set in the canvas) > Settings > Field Code
The following sample code will display the value from the Updated datetime field on a Blank space field, by clicking a button.
You will need to place a Blank space field into your app's form, and name the Element ID "my_space_field" in the Blank space field's settings. The tutorial here shows how to set your Blank space field's settings.
Step 3. Field type and format
You may have noticed that the date formats in the Blank space field and the Updated datetime field are different.
Make sure you check the Field Types and Date Formats pages as formats of data displayed on HTML and data retrieved by API may look different.
Step 4. Be careful when using kintone.app.record.get()
Check the notes written about the kintone.app.record.get() API.
Due to this, the following code will be incorrect, and will not work.
Step 5. The event object
The previous samples returns an Event object.
To understand the event object more, let's check back on the Record Details Event page.
The property information of the event object is listed in the page.
Notice that the event object already has the same return value as the values obtained with kintone.app.record.get().
Step 6. Retrieving record values from the event object
The below sample will retrieve the value of the Updated datetime field from the event object instead of using kintone.app.record.get().
Let's move to the next tutorials!