How to Avoid Regressions
Overview
This article introduces example customizations that should be avoided on Kintone. Kintone allows developers to customize the UI of Kintone through JavaScript. There are cases though, where regressions may occur after Kintone updates, as HTML elements of the Kintone product may also be updated. This article will run through DOM manipulations and URL Usages which are the most at-risk for causing regressions.
DOM Manipulation Examples
HTML element references
When adding display elements such as buttons to a page in Kintone, the element should be added to a Space field element with the Get Space Element API or the Record Header Menu Space element with the Get Record Header Menu Element API .
|
|
Elements should be added using a Space element and a Kintone API that retrieves Space elements. Specifying ID and class names of elements directly is not recommended due to possible changes to the HTML structure after product updates. For example, the following code is not recommended.
|
|
The class name recordlist-cell-gaia is retrieved directly and has changes made to the element. Should there be a Kintone update where this class name in the HTML of the page is changed, the customization would no longer work. The same rule applies to using jQuery. For example, code specifying jQuery('.recordlist-cell-gaia') is also not recommended.
Referring to HTML tags as follows is also not recommended.
|
|
In conclusion, adding elements to places other than those retrievable by Kintone APIs are strongly discouraged.
Positioning elements using positioning CSS
As stated in the HTML element references section, HTML elements should be added to a Kintone page by retrieving a Space element with a Kintone API and adding the HTML element there. However, when adding position CSS properties to an HTML element, issues may occur due to the possibility of the style of the parent element changing. The following code shows an example.
|
|
HTML element operations
The Get Record Field Element API is a method used primarily for making styling changes to Kintone fields like the following.
|
|
On the other hand, this API may not work for making changes other than styling changes. For example, attaching an event handler directly to the retrieved Space field element is not recommended.
|
|
For using mouse or keyboard input events, the following steps are recommended.
- Retrieve the Space field element
- Add the required element such as a text box to the retrieved element
- Use the events for the created text box element
- Input the text box values into a Kintone field (such as after the Save buton is clicked)
URL Usage Examples
URL references
The Kintone URL is subject to change after a product update. For example, it is possible to implement a customization only to a specified Kintone Space (not to be confused with a Space field element or Record Header Menu Space element mentioned previously) by referencing the URL of the Kintone Space in the code uploaded to the System-wide JavaScript Customization settings (refer to the Customizing the Whole Kintone with JavaScript and CSS article from the Kintone Help Center for more information). However, should the URL change in a product update, the customization will run into errors.
URL specification
Similarly, there is a possibility that the following URL specifications will not work due to a product update.
|
|
Using URL parameters (Query Strings)
It is possible to pass data to Kintone from outside the subdomain by using a URL parameter when opening the Kintone page. There is a possibility though that this method will not work due to a product update. To use external data, use the external service's REST API to retrieve data along with Kintone events such as the Record List Onload event. For more information on Kintone events, refer to the Event Handling article.