RepotoneU Excelプラグインボタンの非表示

RepotoneU Excelをプラグインで設定しボタンを配置しました。

プロセス管理のステータスとの連携を行い、ステータスに応じてボタンを非表示にしたく次のコードを書き、動作しました。

ただ、ブラウザ開発者ツールのコンソールから、次の注意が発生しますが対応する書き方はありますか”kintone.events.onによるapp.record.detail.showの登録は、同期的に行ってください。非同期に登録すると、イベントハンドラーが実行されない場合があります。 https://r.cybozu.com/dev/ja/k/user/show_events.html”。

(function(){
'use strict';

window.addEventListener('load', function(event){
kintone.events.on('app.record.detail.show', function(event){
var record = event['record'];

switch(record['ステータス']['value']){
case '起案':
document.getElementById('repotoneue-button-0').style.display = 'block';
document.getElementById('repotoneue-button-1').style.display = 'block';
document.getElementById('repotoneue-button-2').style.display = 'none';
break;
case '注文書作成':
document.getElementById('repotoneue-button-0').style.display = 'none';
document.getElementById('repotoneue-button-1').style.display = 'none';
document.getElementById('repotoneue-button-2').style.display = 'block';
break;
default:
document.getElementById('repotoneue-button-0').style.display = 'none';
document.getElementById('repotoneue-button-1').style.display = 'none';
document.getElementById('repotoneue-button-2').style.display = 'none';
break;
}
return event;
});
});
})();

カスタマイズjs→プラグインjsといった順番で読み込まれるため、setTimeoutを使うのが良いかと思います。

(function(){
'use strict';

kintone.events.on('app.record.detail.show', function(event){
var record = event.record;

setTimeout(function() {
var recordData = kintone.app.record.get(), rec = recordData.record;

switch(rec['ステータス'].value){
case '起案':
document.getElementById('repotoneue-button-0').style.display = 'block';
document.getElementById('repotoneue-button-1').style.display = 'block';
document.getElementById('repotoneue-button-2').style.display = 'none';
break;
case '注文書作成':
document.getElementById('repotoneue-button-0').style.display = 'none';
document.getElementById('repotoneue-button-1').style.display = 'none';
document.getElementById('repotoneue-button-2').style.display = 'block';
break;
default:
document.getElementById('repotoneue-button-0').style.display = 'none';
document.getElementById('repotoneue-button-1').style.display = 'none';
document.getElementById('repotoneue-button-2').style.display = 'none';
break;
}
}, 0);

return event;
});
})();

この方法で動作しました!

setTimeoutは思いつきませんでした。

ありがとうございます。