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カスタマイズ中級者(2) 〜Promiseのかわりにasync/await編〜 article.
Customization Flow
- From App C, it will fetch records from App A.
- It will then extract the
company_ID
from each record - It will pass the
company_ID
as a parameter to App B to get the person's name associated with the company.
Code / Attempts
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;
});