ボタン押下 同期的処理

お世話になっております。

初心者のためscriptが見づらくなっていると思いますが、ご教授お願い致します。

現在業務管理アプリのカスタマイズを行っており、想定した動きを作ることが出来たのですが、
ボタンクリック時に別アプリから取得している社員マスタの情報を全て取得できていないことが分かりました。
コンソール上のエラーは特にありません。

一覧画面起動時の処理は「kintone API で Promise を使ってみよう!」の記事を参考に同期的に処理できているのではないかと思うのですが、
前月ボタンクリック時、翌月ボタンクリック時に表示される担当者のリストが少なくなっている状況です。

JavaScriptの仕様についてですが、一覧画面起動時に作成した担当者コードと担当者名の配列の内容はどのように保存されているのか理解できておりません。

ボタンクリック時に配列の情報が残ったままの場合でも、残っていない場合でも、
表示される担当者のリストの一部が表示されないという状況を考えることが出来ません。
(全て表示される or 一人も表示されない のどちらかではないかと考えてしまいます。)

ボタンクリック時に全ての担当者名を表示するためには、どのように修正すればいいのかご教授をいただければ幸いです。

以下コード等です。

<HTML>

<div class = “timetable”>
<button id = ‘prev’ class = ‘timetable-preb-button’>前月</button>
<span id = ‘month’ class = ‘timetable-month’>○○年○○月</span>
<button id = ‘next’ class = ‘timetable-next-button’>翌月</button>
</div>

<div id = ‘tableArea’>

<table border = ‘1’ class = ‘type01’ id = ‘sampleTable’>
<thead id = ‘cstap_thead’>
<tr>
<th>担当者コード</th>
<th>担当者名</th>
<th>監査</th>
<th>入力</th>
<th>決算</th>
<th>その他</th>
<th>合計時間</th>
<th></th>
</tr>
</thead>
<tbody id=‘my-tbody’>
</tbody>
</table>

<JavaScript>
(function(){
'use strict';

//月を変更できるように設定
const today = new Date();//今日の日付を取得

//現在表示している日付を保存
let nowday = today;

//社員一覧アプリにてコードと名前を取得する
const codePerson = [];
const codePersonName = [];

//////////////
//function集//
//////////////

//mmをhh:mmに戻す
function time(putTime){
const h = Math.floor(putTime / 60);//商
const m = putTime % 60;//余り

//hh:mmに戻す
putTime = h + '時間' + m + '分';

return putTime;
}

//日付から月初,月末,年,月,翌月1日,先月末日を返す関数 
function getStartEndDay(day){
const thisYear = day.getFullYear();//今年を取得
const prevMonth = day.getMonth();//先月を取得
const thisMonth = day.getMonth() + 1;//今月を取得
const nextMonth = day.getMonth() + 2;//翌月を取得
const lastday = new Date(thisYear,thisMonth,0);//当月末日を取得
const nextday = new Date(thisYear,thisMonth,1);//翌月1日を取得
const prevday = new Date(thisYear,prevMonth,0);//先月末日を取得
const thisLastDate = lastday.getDate();
const dayStart = thisYear + '-' + ('0' + thisMonth).slice(-2) +'-01';
const dayEnd = thisYear + '-' + ('0' + thisMonth).slice(-2) +'-' + thisLastDate;

return [dayStart,dayEnd,thisYear,thisMonth,nextday,prevday];
}

//業務管理アプリにて日付をクエリ化し条件の全レコードを取得
function fetchRecords(appId,opt_dayStart,opt_dayEnd,opt_offset,opt_limit,opt_records){
const offset = opt_offset || 0;
const limit = opt_limit || 100;
let allRecords = opt_records || [];
const query = 'day <= "' + opt_dayEnd + '" and '+ 'day >= "' + opt_dayStart + '"';
const params = {'app':appId,'query':query + 'order by レコード番号 asc limit ' + limit + ' offset ' + offset};
return kintone.api(kintone.api.url('/k/v1/records', true), 'GET', params).then(function(resp) {
allRecords = allRecords.concat(resp.records);
if(resp.records.length === limit){
return fetchRecords(appId,opt_dayStart,opt_dayEnd,offset + limit,limit,allRecords);
}
return allRecords;
});
}

function not0time(time,cell){
if(time != '0時間0分'){
cell.innerText = time;
}
}

function makeData(e,day){

//変数を定義
const dayStart = getStartEndDay(day)[0];
const dayEnd = getStartEndDay(day)[1];
const year = getStartEndDay(day)[2];
const month = getStartEndDay(day)[3];

//表示月を変更
const nameMonth = document.getElementById('month');
nameMonth.innerText = year + '年' + month + '月';

//htmlからテーブルを取得
const myRecordSpace = document.getElementById('my-tbody');
myRecordSpace.innerText = '';//とりあえず空にしておく

const appId = kintone.app.getId();
fetchRecords(appId,dayStart,dayEnd).then(function(resp){

//担当者毎に集計
for( let person = 0; person < codePerson.length; person++){

const row = myRecordSpace.insertRow(myRecordSpace.rows.length);
const cell1 = row.insertCell(0);
const cell2 = row.insertCell(1);
const cell3 = row.insertCell(2);
const cell4 = row.insertCell(3);
const cell5 = row.insertCell(4);
const cell6 = row.insertCell(5);
const cell7 = row.insertCell(6);
const cell8 = row.insertCell(7);

let timeAudit = 0;//月次訪問&来社時間
let timeInput = 0;//入力時間
let timeSettlement = 0;//決算時間
let timeOther = 0;//その他
let timeAll = 0;//合計時間

for(let i = 0; i < resp.length; i++) {
const record =resp[i];

//担当者コードがpersonと一致するときに実行
if(record.code_charge1.value === codePerson[person]){

//hh:mmを一度数字に変換し加算する
const h = record.作業時間.value.substring(0,2);//時
const m = record.作業時間.value.substring(3,5);//分

//業務ごとに加算する
if(record.content.value ==='月次訪問' || record.content.value ==='来社'){
timeAudit += parseFloat(h * 60);
timeAudit += parseFloat(m);
timeAll += parseFloat(h * 60);
timeAll += parseFloat(m);
} else if(record.content.value ==='入力'){
timeInput += parseFloat(h * 60);
timeInput += parseFloat(m);
timeAll += parseFloat(h * 60);
timeAll += parseFloat(m);
} else if(record.content.value ==='決算'){
timeSettlement += parseFloat(h * 60);
timeSettlement += parseFloat(m);
timeAll += parseFloat(h * 60);
timeAll += parseFloat(m);
} else{
timeOther += parseFloat(h * 60);
timeOther += parseFloat(m);
timeAll += parseFloat(h * 60);
timeAll += parseFloat(m);
}
}
}

//mmをhh:mmに戻す
timeAudit = time(timeAudit);
timeInput = time(timeInput);
timeSettlement = time(timeSettlement);
timeOther = time(timeOther);
timeAll = time(timeAll);

cell1.innerText = codePerson[person];//担当者コード
cell2.innerText = codePersonName[person];//担当者名
not0time(timeAudit,cell3);//監査時間
not0time(timeInput,cell4);//入力時間
not0time(timeSettlement,cell5);//決算時間
not0time(timeOther,cell6);//その他時間
not0time(timeAll,cell7);//合計時間

const recUrl = 'https://kinkei.s.cybozu.com/k/186/?view=5575299';
const query = 'f5574537<="' + dayEnd + '" and f5574537 >="' + dayStart + '" and f5574463 = "' + codePerson[person] + '"';
const tmpA = document.createElement('a');
tmpA.href = recUrl + '&q=' + query;
tmpA.innerText = 'レコード一覧を表示';
cell8.appendChild(tmpA);

}
});

//レコード一覧画面表示で実行
kintone.events.on('app.record.index.show',function(event){

//担当者別業務時間集計でなければ実行しない
if(event.viewId !==5575294){
return;
}

//担当者リストを取得
const body = {
'app':199,
'query':'担当者コード < 999 order by 担当者コード asc limit 500 offset 0',
'fields':['担当者コード','担当者名']
};

return kintone.api(kintone.api.url('/k/v1/records',true),'GET',body).then(function(resp){
for (let i =0; i < resp.records.length; i++){
codePerson.push(resp.records[i].担当者コード.value);
codePersonName.push(resp.records[i].担当者名.value);
}

//担当者リストの取得が終わってから実行
}).then(function(resp2){
//todayで実行
makeData(resp2,nowday);

//前月ボタン押下で実行
const prevButton = document.getElementById('prev');

prevButton.onclick = function(){
const prevDay = getStartEndDay(nowday)[5];
nowday = prevDay;//表示月を更新

//テーブルのクリア後実行
clearTbody('my-tbody');
makeData(resp2,nowday);
};
//翌月ボタン押下で実行
const nextButton = document.getElementById('next');

nextButton.onclick = function(){
const nextDay = getStartEndDay(nowday)[4];
nowday = nextDay;//表示月を更新

//テーブルのクリア
clearTbody('my-tbody');

//実行
makeData(resp2,nowday);
};
});

});

})();

自己解決しました。

リストを取得できていないわけではなく、別に記述してるjsが影響して表示されていなかっただけのようです。

お騒がせしてしまい申し訳ございませんでした。