〇実現したいこと
部完日と目標日の間が14日より短くなると、レコードの背景色を赤にする。
(目標日を変更すると背景色が戻る)
〇以下のエラーが発生
ncaught TypeError: Cannot read properties of null (reading ‘length’)
at download.do?app=96&contentId=2112&jsType=DESKTOP&hash=456ca8a58ea0edc28d173704f81576d8ff8812eb:11:32
at index.js:254:221
at new hk (index.js:125:470)
at Xw (index.js:254:200)
at index.js:253:507
at e.G (index.js:127:367)
at yk (index.js:129:392)
at tk (index.js:129:275)
at hk.H (index.js:932:102)
at ak (index.js:125:317)
〇実行したコード
(() => {
'use strict';
kintone.events.on(['app.record.index.show'], async event => {
const deadline = kintone.app.record.getFieldElement('部完日');
const deadlineSupply = kintone.app.record.getFieldElement('目標日');
const Id = kintone.app.record.getId();
for (let i = 0; i < Id.length; i++) {
const deadlineElement = deadline[i];
const deadlineSupplyElement = deadlineSupply[i];
if (new Date(deadlineElement.value) - new Date(deadlineSupplyElement.value) < 14 * 24 * 60 * 60 * 1000) {
const recordRow = kintone.app.getHeaderMenuSpaceElement();
recordRow.style.backgroundColor = '#ED1A3D';
recordRow.style.color = '#fff';
recordRow.style.fontWeight = 'bold';
}
}
return event;
});
})();
こちらの問題を解決したいです。
よろしくお願いいたします。