# How to Speed up My Kintone Customization?

**URL:** <https://forum.kintone.dev/t/how-to-speed-up-my-kintone-customization/774>\
**Category:** General\
**Created:** [May 25, 2023, 11:22am UTC](https://forum.kintone.dev/t/how-to-speed-up-my-kintone-customization/774 "2023-05-25T11:22:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![H\_Nar](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/h_nar/32/353_2.png) [@H\_Nar](https://forum.kintone.dev/u/H_Nar)\
**Post date:** [May 25, 2023, 11:22am UTC](https://forum.kintone.dev/t/how-to-speed-up-my-kintone-customization/774/1 "2023-05-25T11:22:26Z")

</div>

# How to Speed up My Kintone Customization?

## Question / Problem

Hello, I have a simple JavaScript customization that is running slow.  
How can I speed it up?

## Current Situation

I have 3 Kintone Apps linked by the `company_ID` field.

- App A stores the company's name using the `Company_Name_Hangul` field.
- App B stores the person's name using the `name` field.
- App C - I want to do something in this app.

The JavaScript customization is running on App C.

I am using the async/await code from the [目指せ！JavaScriptカスタマイズ中級者（２） 〜Promiseのかわりにasync/await編〜](https://cybozudev.zendesk.com/hc/ja/articles/900001244323) article.

### Customization Flow

1. From App C, it will fetch records from App A.
2. It will then extract the `company_ID` from each record
3. It will pass the `company_ID` as a parameter to App B to get the person's name associated with the company.

### Code / Attempts

```javascript
var createRows = async function (rows, recordEnd, records) {
  for (var i = 0; i < recordEnd; i++) {
    var company = records[i].company_ID.value;
    var name = records[i].name.value;
    var Company_Name_Hangul = '';
    var Headquarters_Address = '';
    var Zip_Code = '';
    var body = {
      "app": 17,
      "query": "Company_ID=" + company + " order by $id asc limit 100 offset 0",
      "fields": ["Headquarters_Address", "Zip_Code", "Company_Name_Hangul"]
    };
    const resp1 = await kintone.api('/k/v1/records', 'GET', body);

    var addr1 = Headquarters_Address.split("\r\n")[0];
    var addr2 = Headquarters_Address.split("\r\n")[1];
    rows.push([{ content: addr1, styles: { minCellHeight: 1, fontSize: 8.5, cellPadding: 1 } }])
    rows.push([{ content: addr2, styles: { minCellHeight: 1, fontSize: 8.5, cellPadding: 1 } }])
    rows.push([{ content: Company_Name_Hangul, styles: { minCellHeight: 1, fontSize: 10.5, cellPadding: 1 } }])
    rows.push([{ content: name, styles: { minCellHeight: 1, fontSize: 12.5, cellPadding: 0, halign: 'right', fontStyle: 'bold' } }])
    rows.push([{ content: Zip_Code, styles: { minCellHeight: 1, fontSize: 10.5, cellPadding: 1, halign: 'right', fontStyle: 'bold' } }])
    rows.push([{ content: 'empty', styles: { minCellHeight: 1, fontSize: 10.5, cellPadding: 1 } }])
  }

  var event1 = generatePDF(rows);

  return rows;
}

kintone.events.on(events, function (event) {

  button.addEventListener('click', event => {

    var subject = ''
    var contents = ''
    fetchRecords(20).then(function (records) {
      console.log(records);
      var cnt = records.length

      //insert
      var label = ''
      const recordEnd = cnt;
      var row = [];
      row = createRows(row, recordEnd, records);

      console.log(label);
    });
  });

  header.appendChild(button);

  return event;
});

```

## Referenced Resources

- [目指せ！JavaScriptカスタマイズ中級者（２） 〜Promiseのかわりにasync/await編〜 - cybozu developer network](https://cybozudev.zendesk.com/hc/ja/articles/900001244323)

---

<div class="post-metadata">

**Author:** ![Chris](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/chris/32/44_2.png) [@Chris](https://forum.kintone.dev/u/Chris)\
**Post date:** [May 30, 2023, 6:08pm UTC](https://forum.kintone.dev/t/how-to-speed-up-my-kintone-customization/774/2 "2023-05-30T18:08:33Z")

</div>

Hello @H_Nar ,

At times, users may experience this issue when utilizing the Get Records "GET" ('/k/v1/records') method.

As indicated in the following documentation (Japanese version), performance can be improved by specifying the required field code within the fields parameter. This may be especially useful if the Get Records "GET" method is demonstrating slow performance.

> **[取得するフィールドを指定することで、kintoneのレコード一括取得の時間を短縮する](https://cybozudev.zendesk.com/hc/ja/articles/360021064411)**
>
> はじめに
> この記事では、レコード一括取得REST APIで、取得するフィールドを指定することで、APIの実行時間が短縮できることを説明します。とても簡単な内容ではありますが、kintoneアプリの構成やレコード取得の目的によっては、処理時間の削減に効果がありますので、覚えておいていただければと思います。
> 方法
> フィールドを指定する方法はとても簡単です。レコード一括取得REST APIのfie...

However, given that you have already specified the fields parameter, the issue may stem from a different cause.

As you may be aware, the processing time for APIs can be significantly influenced by several factors such as the number of fields and records, permissions within an app, and network conditions. Therefore, pinpointing the exact cause can be challenging.

At this point, I would recommend a few steps to investigate further:

- Create a new app and run the same process to determine if the issue recurs.
- If you have a very large number of records, test with an app that has fewer records.
- You seem to have the generatePDF function running in a loop within the createRows function, this could be a potential source of delay, it might be worthwhile to check the execution time here.

I hope these steps might assist you in diagnosing the issue.

The following page might be useful, too:

> **[Get All Records from an App: The Offset Method vs The Seek Method](https://kintone.dev/en/tutorials/development-productivity/get-all-records-from-an-app-offset-vs-seek-method/)**
>
> This article introduces how to retrieve data of all records from a Kintone App, comparing performance with the Offset and Seek Method.
