申請書アプリの申請書詳細画面の請求書作成ラジオボタンが済のとき請求書作成ボタンを非表示にし、未完のときに請求書作成ボタンが表示され、押下後請求書アプリの請求書作成画面に遷移し登録ができる処理が以下のコードです。ここからが質問なのですが、請求書作成後に申請書詳細画面の請求書作成ラジオボタンが済にステータス変更がされるための処理を教えていただきたいです。
(function() {
“use strict”;
kintone.events.on(‘app.record.detail.show’, function(event) {
var field_check = event.record.reception_number.value;
//申請書画面の引継ぎ対象フィールドでの入力を確認
if (!field_check) {
return;
}
var mySpaceFieldButton = kintone.app.record.getSpaceElement(‘billbutton’);
//ボタンを設置
var $button = $(‘<button title=“請求書アプリに追加する” class=“kintoneplugin-button-normal”>請求書作成</button>’);
$button.click(function() {
//申請書画面の関連レコードのアプリIDの取得
var related = kintone.app.getRelatedRecordsTargetAppId(‘relation’);
//関連レコードの請求書作成画面のURLへのジャンプ
var new_window = window.open(“/k/” + related + “/edit”);
new_window.addEventListener(“load”, function() {
window.postMessage(new_window.kintone !== null, location.origin);
});
window.addEventListener(“message”, (function() {
return function field_set() {
//請求書画面の新規レコード側のフィールドを指定してsetする
var new_app = new_window.kintone;
var new_record = new_app.app.record.get();
new_record.record.reception_number.value = field_check;
//ここから新規で開いた請求書画面でルックアップ先の更新処理を行う
new_record.record.reception_number.lookup = true;
new_app.app.record.set(new_record);
window.removeEventListener(“message”, field_set, false);
};
})(), false);
});
$(mySpaceFieldButton).append($button);
});
})();
(function () {
“use strict”;
// 申請書詳細画面の表示イベントをフック
kintone.events.on(‘app.record.detail.show’, function (event) {
var record = event.record;
var radioButtonValue = record[‘bill_01’].value; // ラジオボタンのフィールドコードに適切なフィールドコードを指定
// ラジオボタンの値に応じて追加登録ボタンの表示・非表示を切り替え
if (radioButtonValue === ‘済’) {
hideAddButton();
} else {
showAddButton();
}
return event;
});
// 追加登録ボタンを非表示にする関数
function hideAddButton() {
var addButton = kintone.app.record.getSpaceElement(‘billbutton’); // 追加登録ボタンのスペースフィールドコードに適切なフィールドコードを指定
if (addButton) {
addButton.style.display = ‘none’;
}
}
// 追加登録ボタンを表示する関数
function showAddButton() {
var addButton = kintone.app.record.getSpaceElement(‘billbutton’); // 追加登録ボタンのスペースフィールドコードに適切なフィールドコードを指定
if (addButton) {
addButton.style.display = ‘block’;
}
}
})();