Kintone Coding Guidelines

Contents

Overview

By using Kintone's JavaScript / CSS Customization features, the UI and features of Kintone and it's Applications can be customized.
This page introduces guidelines for Kintone JavaScript customization that you should read before you start coding for Kintone customizations.
Please refer to our Kintone Help Pages for details on how to apply JavaScript customization to your Apps.

Coding Guidelines

Character Encoding

Always use UTF-8 without BOM.

Namespaces and Variables

Do not overwrite existing global objects.
Declare local variables inside the scope of anonymous functions or within block scope. Do not declare variables as global variables.

If a variable needs to be used between function scopes, use one of the following:

  • Use JavaScript bundlers such as webpack
  • Use a namespace object
Avoid using or overwriting global variables
1
2
3
4
(() => {
  globalVariable = 1; // Do not declare global variables.
  const localVariable = 1; // Instead declare your local variables within the immediately invoked function.
})();

Declare Variables Within the Scope of Blocks

1
2
3
4
5
6
7
8
{
  // Bad Practice: globalVariable is overwritten due to overlapping scope and using var to declare.
  globalVariable1 = 1;
  var globalVariable2 = 1;
  // Good Practice: Variables are declared locally, within the block scope, as declaring variables with let respects block scope.
  const localVariable1 = 1;
  let localVariable2 = 1;
}
Add to or reference existing objects rather than editing
1
2
3
4
5
6
7
8
(() => {
  // Bad Practices:
  kintone.foo = 'bar'; // Do not edit the existing global object.
  const foo = kintone.foo; // Avoid referencing global objects.
  // Good Practices:
  myNameSpace = {}; // Create a new object instead.
  myNameSpace.foo = 'bar'; // Add the desired properties to that object.
})();

id / class Attributes That Are Used in Kintone

The id/class attributes of each element used in Kintone may be changed without any notice.
The DOM structure may also change without any notice.

When creating Kintone customizations, refrain from editing the following:

  • id or class of HTML elements
  • The DOM structure of any elements not obtained via the Kintone JavaScript API

When editing the DOM, it is highly recommended to utilize the Kintone JavaScript API, as the classname, id or other DOM properties may be changed at any time without warning by Kintone.

Customization on Elements Retrieved with JavaScript APIs

As Kintone's CSS may affect the elements, they may not always look the same.
For APIs that can get elements, refer to following link:
Kintone JavaScript API: Get Elements

Retrieving the URL

Use the kintone.api.url() or the kintone.api.urlForGet() method to retrieve the Kintone URL.

Contents That Cannot Be Customized with JavaScript API and CSS

The following App pages will not run their JavaScript/CSS customizations if attached to bodies of Spaces/Threads/Announcements:

  • Record list
  • Graph

Check Operations on Several Web Browsers

It is recommended to use different Web browsers to test the customization.
Depending on the JavaScript program that is uploaded onto Kintone, some features of Kintone may not function correctly.
Check that the customization works correctly in different browser types and versions.
For Kintone’s system requirements, refer to the following page
System Requirements (External link)

Consider the Effect to the Kintone Service

Avoid Sending Large Amounts of Requests Within a Short Time Period

Automated programs sending numerous requests or running multiple parallel requests can degrade performance and slow responses. Please note that excessive requests imposing a heavy load on our servers may result in access restrictions on your Kintone environment.

Set an Appropriate User Agent

Please set an appropriate value in the User-Agent header, so that we can identify what services or tools the requests are coming from.
Refer to the guidelines on user-agents through the below link:

Avoid Parallel Processing

Simultaneously adding, updating, and deleting Apps or Records can lead to deadlocks and subsequent errors. Therefore, please avoid processing Kintone REST API in parallel as much as possible.

Effects of Kintone Updates

After Kintone has an update, there may be a possibility that the JavaScript and CSS files that you uploaded do not function correctly. In this case, please edit the file contents and re-upload them.
To greatly reduce the chance of this happening, please make sure to read through the JavaScript API documents and use the Kintone JavaScript API in your codes.

Change Policy for Public API Specifications

Security

To prevent security issues from your JavaScript programs, create your programs following the guide below:
Secure Coding Guidelines