Learn how to create a mobile app in Unifinity that works with kintone.
In this article, we will show you how to register records to a lookup field in kintone using kintone's REST API.
In a previous post.User Authenticationwill be required, so please check accordingly.
You can download a sample project of the Unifinity kintone application used in the explanation below. We hope you will take advantage of it.
kintone: Lookup Registration & Master for Registration
Unifinity: kintone lookup registration application
Overview of the application to be created
Acquire the records of the master for lookup registration in kintone and store them in Unifinity's DB. A mobile application is then created that registers records in the lookup fields based on the data in said master.
Setting up kintone
This time, create two applications: one to register lookup records and a master for registration that will be the source for copying lookups.
Please note that when setting up the master application for registration, the field from which you are copying (in this case, name) must be set to non-duplicate. Also, please register about 2~3 records in the master for registration.
Master for registration
Registration
In order to link, the kintone subdomain name, app ID, and field code for each field are required.
The subdomain name and app ID can be found in the following part of the URL when connecting to the app.
The field code for each field can be checked from the application's settings screen.
Unifinity collaboration settings
This time,
(1) Acquire the records of the master for registration and store them in the DB,
(2) Select a value from the stored data and register it in a lookup field.
We will explain screen creation, DB creation, and process creation.
0. Preparation
In my previous article.User Authenticationin the application.
Also, set the global variable for the property to the subdomain name identified in the kintone configuration.
1. screen creation
(1) Place a combo box to select the registered value of the lookup field.
(2) Place a button to register the record in kintone.
The screen creation is now complete (there are some areas to be updated after setting up 2.3.)
2. creation of DB
Create a DB in Unifinity to store information on data retrieved from kintone.
(1) Create a DB for storage.
After creating the data file, enter an easy-to-understand name for the item name and physical item name for the item you wish to retrieve from the kintone application.
Also, check the Empty Permission box for items that may be empty of data.
*Please note that physical item names must be set using alphabet + numbers (must start with an alphabet).
DB creation is now complete.
3. process creation
First, create an operation to retrieve records from the master for registration and store them in the DB.
(1) Subdomain name calling
#2 | ."Variable/Global variable acquisitionto read the kintone subdomain set in the global variable. |
(2) Calling user authentication information
#4 | ."Database/RetrievalUse the "User Authentication Information (X-Cybozu-Authorization:●●●)" to read the "User Authentication Information (X-Cybozu-Authorization:●●●)" stored in the DB. (0. described in Preparation)User Authenticationin your application and specify the DB there.) |
(3) Request data acquisition to kintone
#6 | ."Database/DeleteDelete past kintone data stored in the DB created in 2. |
#7 | ."String Functions/Concatenationand generate the RESTAPI URI (https://(subdomain name).cybozu.com/k/v1/records.json) as determined by KINTONE. This time, we concatenate the contents of #2, which invokes the subdomain name, with "/k/v1/records.json". For more information on kintone's RESTAPI, seethis way (direction close to the speaker or towards the speaker)for more information. |
#8 | ."Network/HTTP requestto send data to kintone. Set each item as follows The value corresponding to *app is left blank, but please enter the appID of the app you wish to retrieve. |
(4) Confirm the contents of acquired data
#10 | ."Dictionary/AcquisitionUse the "Key: Body" to obtain the key: Body. |
#11 | ."Dialog/Input" as follows to display the results of #10. This is used as a confirmation when creating the application. When running in production, please check the disabled checkbox at the leftmost line of the processing line. The response obtained at this point should be used as the basis for subsequent processing,this way (direction close to the speaker or towards the speaker)It is recommended to put it in a JSON parser such as This one is a bit more difficult, so please contact us if you need help. |
(5) Store kintone response in DB
#13 | ."Dictionary/JSON readto convert #10 JSON to dictionaries. |
#14 | ."Dictionary/Acquisitionto get the key: records. |
#15 | Since the contents of the records retrieved in #14 contain multiple records arranged in an array, the "Control statement/Foreach (repeat start)The process of "1." is performed and stored in the DB one record at a time. In addition, the corresponding "Control statement/repeat endis needed at the end of the process. |
#16 | ."Dictionary/AcquisitionUse "#15" to get the key: kintone field code (in this case, a string) from the result of #15. |
#17 | ."Dictionary/AcquisitionUse "#16" to get the key: value (fixed) from the result of #16. |
#18 | ."Dictionary/AcquisitionUse "#15" to get the key: kintone field code (in this case, a string) from the result of #15. |
#19 | ."Dictionary/AcquisitionUse "#18" to get the key: value (fixed) from the result of #18. |
#20 | ."Database/AdditionAdd the data obtained from kintone to the DB created in 2. as follows using "1. |
#21 | ."Control statement/repeat endUse "+" to terminate the process. |
(6) Perform the actions created in (1) through (5) at login.
Add the following processing to the end of the user authentication logic
#18 | ."Control statement/process executionThe process created in (1) through (5) is executed using |
Next, create a behavior that selects a value from the stored data and registers it in a lookup field in kintone.
(1) Subdomain name calling
#2 | ."Variable/Global variable acquisitionto read the kintone subdomain set in the global variable. |
(2) Calling user authentication information
#4 | ."Database/RetrievalUse the "User Authentication Information (X-Cybozu-Authorization:●●●)" to read the "User Authentication Information (X-Cybozu-Authorization:●●●)" stored in the DB. (0. described in Preparation)User Authenticationin your application and specify the DB there.) |
(3) Format data into a format for sending to kintone
When registering data in kintone, the format specified by kintone (e.g.This time, here it is.to format the data.
It will need to be formatted into the following format, and we will show you how to do this below.
#6 | ."Control/Content AcquisitionSelect what is entered on the screen using the |
#7 | ."Dictionary/CreationThe "I" will be shaped using the "I". "value": To create the format "(field value)", enter value for the key and select the contents of #6 for the value. |
#8 |
Next, create the format "(field code)": {#7}. |
#9 |
Finally, create the format {"app": "(ID of app)", "record": {#8}}. |
#10 |
Finally, the well-formed elements are processed into JSON format. |
(4) Send data to kintone
When registering data in kintone, the URI (URI) specified by kintone (see below) must be used.This time, here it is.to send the data to the (M).
#12 | ."String Functions/Concatenationand generate the RESTAPI URI (https://(subdomain name).cybozu.com/k/v1/record.json) as determined by KINTONE. This time, the contents of #2, which invokes the subdomain name, are concatenated with "/k/v1/record.json". |
#13 |
."Network/HTTP requestto send data to kintone. |
4. stringing
This time, we will link the screen to the database and processing.
(1) Connecting combo boxes and databases on the screen
Select the combo box, and in the Data List, select the DB created in 2. for the table name, the key field name and value field name, and the item to be registered in the lookup field.
The key field is the value returned when the control/content is retrieved, and the value field is the value to be displayed in the combo box list.
(2) Linking buttons and processes on the screen
Finally, the record registration button is connected to the record registration process to the lookup created in step 3 to complete the process.
In the next issue, we will show you how to create an application that registers records to a user selection field in KINTONE.
The kintone application and sample projects used in this explanation can be downloaded from the following links.
kintone: Lookup Registration & Master for Registration
Unifinity: kintone lookup registration application