Learn how to create a mobile app in Unifinity that works with kintone.
In this article, we will show you how to retrieve kintone records 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: Record Retrieval Application
Unifinity: kintone record retrieval application
Overview of the application to be created
Create a mobile app that retrieves records from kintone and stores and displays them in Unifinity's DB.
Setting up kintone
This time, please set up applications for date/time, strings, numbers, radio buttons, check boxes, drop-downs, user selection, and lookups (+ string of lookup results), and register about 2~3 records of data. Since lookups are used, please also set the application to which lookups will be applied.
These records are retrieved by the mobile application.
Other commonly used attachment DLs are described in another article.
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 section explains screen creation, DB creation, and process creation.
For basic Unifinity operation, click here.Tutorial Videosfor more information.
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 button to retrieve a kintone record.
(2) Create a screen that displays multiple records obtained. Unifinity offers two possible formats for displaying multiple records, tabular and list, and we will introduce both.
Since the tabular format is less flexible, we recommend the list format for improved readability.
(3) Table format
(3-1) Select the table object and place it in the screen. You can configure the detailed settings in the Data > Contents section, but since this configuration will be performed at the end, you can leave the default settings at this time.
(3-2)Set up a slider linked to the table created above. After placing the slider, go to Data > Contents, select Controls, select the table you created for the screen control name, and set the direction to vertical.
This will allow the slider to scroll the table as well.
(4) List format
(4-1) Select a sub-form object and place it on the screen. Please check the width in Object Basic Information, as it will be used in (4-2).
(4-2) Create a new screen to be displayed on the sub form, and match its size width with the width of the screen in (4-1). Set the height arbitrarily according to the number of items to be displayed.
4-3) Place the number of labels you wish to display as a list on the screen created in (4-2).
In this case, there are three: Record No./Date/String.
(4-4) Then, select the subform of the screen created in (4-1), select the screen from (4-2) in Object > Details, and check the List view.
(4-5) Set up a slider linked to the sub form created above. The settings here are the same as in (3-2).
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. To obtain a date and time, select a date type for the type.
Also, check the Empty Permission checkbox for items where data may be empty.
*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
Create an action when the data acquisition button created on the screen is pressed.
For each item, we will explain the process one by one.
(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 (record number in this case) 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, date and time) from the result of #15. |
#19 | ."Dictionary/AcquisitionUse "#18" to get the key: value (fixed) from the result of #18. For date and time, Unifinity cannot handle the kintone format (YYYYY-MM-DDTHH:MM:SSZ) as is, so processing #20-27 is required. |
#20 | ."String Functions / Get Partialto get the year portion of "YYYYY", the 4 characters from the 0th character. |
#21 | ."String Functions / Get Partialto get the month portion of "MM", and the two characters from the fifth character. |
#22 | ."String Functions / Get Partialto obtain the day portion of "DD", the first 2 characters from the 8th character. |
#23 | ."String Functions / Get Partialto get the time part of "HH", the two characters from the 11th character. |
#24 | The time retrieved by #23 is UTC (Coordinated Universal Time), so to convert it to JST (Japan Standard Time), use the "Calculation/AdditionUse "+9 hours" and do +9 hours. |
#25 | ."String Functions / Get Partialto get the minute part "MM", and then get the two characters from the 14th character. |
#26 | ."String Functions / Get Partialto get the second part of "SS", and then get the two characters from the 17th character. |
#27 | ."Date/CreationSet the data in #20-26 to year, month, date, minute, and second using |
#28 |
."Dictionary/AcquisitionUse "__" to get the key: kintone field code (in this case the string __1 line_) from the result of #15. |
#29 |
."Dictionary/AcquisitionUse "#28" to get the key: value (fixed) from the result of #28. |
#30 |
."Dictionary/AcquisitionUse "#15" to get the key: kintone field code (numerical in this case) from the result of #15. |
#31 |
."Dictionary/AcquisitionUse "#30" to get the key: value (fixed) from the result of #30. |
#32 |
."Dictionary/AcquisitionUse the "#15" to get the key: kintone field code (in this case, radio button) from the result of #15. |
#33 |
."Dictionary/AcquisitionUse "#32" to get the key: value (fixed) from the result of #32. |
#34 |
."Dictionary/AcquisitionUse "#15" to get the key: kintone field code (checkbox in this case) from the result of #15. |
#35 |
."Dictionary/AcquisitionUse "#35" to get the key: value (fixed) from the result of #35. |
#36 |
In the case of multiple choices, they are arrayed ([Choice 1, Choice 2, ...]), so the "String Functions/ReplaceUse "#35" to delete [], replacing "[" with "empty" in the result of #35. |
#37 | As in #36, replace "]" in the result of #36 with "empty". |
#38 |
."Dictionary/AcquisitionUse "#15" to get the key: kintone field code (dropdown in this case) from the result of #15. |
#39 |
."Dictionary/AcquisitionUse "#38" to get the key: value (fixed) from the result of #38. |
#40 |
."Dictionary/AcquisitionUse "#15" to get the key: kintone field code (in this case, user selection) from the result of #15. |
#41 |
."Dictionary/AcquisitionUse "#40" to get the key: value (fixed) from the result of #40. |
#42 |
For user selection, the records are stored as an array in the value of value as shown below. |
#43 | ."Dictionary/Acquisitionand get the key: name (code is not obtained this time) from the result of #42. |
#44 | ."Control statement/repeat endUse "+" to terminate the process. |
#45 |
."Dictionary/AcquisitionUse "__" to get the key: field code of the kintone (in this case, twookup_0) from the result of #15. |
#46 |
."Dictionary/AcquisitionUse "#45" to get the key: value (fixed) from the result of #45. |
#47 |
."Dictionary/AcquisitionUse "__" to get the key: kintone field code (in this case, string __1 line_1) from the result of #15. |
#48 |
."Dictionary/AcquisitionUse "#47" to get the key: value (fixed) from the result of #47. |
#49 | ."Database/AdditionAdd the data obtained from kintone to the DB created in 2. as follows using "1. |
#50 | ."Control statement/repeat endUse "+" to terminate the process. |
#52 | ."Control/UpdateUse "1." to bring the screen table created in 1. up to date. Tables and sub forms linked to the database can be updated to immediately reflect the values stored in the database by executing the update process. |
#53 | ."Control/UpdateUse "1." to bring the subforms of the screen created in 1. up to date. |
4. stringing
This time, we will link the screen to the database and processing.
(1) Linking the table on the screen to the database
Select the table, then select Data Table of Contents. Enter the name of the table to be linked there, the number of rows to be displayed (4 in this case), and check only the column headers. Also, click on Display Items and set the database items to be displayed in the table (three in this case). When selecting the date and time, please enter a format such as "YYYYY-MM-DD hh:mm:ss" in the format.
(2) Connecting sub forms on the screen to the database
First, on the screen to which the sub form is to be transferred, with nothing selected (or click on the black area outside the screen), go to Data Contents and select the name of the table to be linked.
Then select each label, choose Data Contents then Form, and select the name of the field you want to display.
(3) Linking buttons and processes on the screen
Finally, tie the process created in step 3 to the Get Record button to complete the process.
In the next issue, we will show you how to create an application that registers a lookup field in KINTONE.
The kintone application and sample projects used in this explanation can be downloaded from the following links.
kintone: Record Retrieval Application
Unifinity: kintone record retrieval application