ドロップダウンの選択肢に応じて、
フィールドコードを下記のように制御したいと考えております。
まずはドロップダウンの値が変更された際に、
必須な場所に”必須項目!”というエラー表示を出す。
という方法を考え、
(function () {
"use strict";
var events = ['app.record.edit.change.ドロップダウン'
,'app.record.create.change.ドロップダウン'
,'app.record.index.edit.change.ドロップダウン'];
kintone.events.on(events, function(event){
var record = event.record;
switch (record['ドロップダウン']['value']){
case "選択肢A":
if ( record['field_1']['value'] === "" ){
record['field_1']['error'] = "必須項目!";
}
if ( record['field_2']['value'] === "" ){
record['field_2']['error'] = "必須項目!";
}
if ( record['field_3']['value'] === "" ){
record['field_3']['error'] = "必須項目!";
}
if ( record['field_4']['value'] === "" ){
record['field_4']['error'] = "必須項目!";
}
if ( record['field_5']['value'] === "" ){
record['field_5']['error'] = "必須項目!";
}
if ( record['field_6']['value'] === "" ){
record['field_6']['error'] = "必須項目!";
}
if ( record['field_7']['value'] === "" ){
record['field_7']['error'] = "必須項目!";
}
if ( record['field_8']['value'] === "" ){
record['field_8']['error'] = "必須項目!";
}
if ( record['field_9']['value'] === "" ){
record['field_9']['error'] = "必須項目!";
}
break;
case "選択肢B":
if ( record['field_1']['value'] === "" ){
record['field_1']['error'] = "必須項目!";
}
if ( record['field_2']['value'] === "" ){
record['field_2']['error'] = "必須項目!";
}
if ( record['field_3']['value'] === "" ){
record['field_3']['error'] = "必須項目!";
}
record['field_4']['disabled'] = true;
record['field_5']['disabled'] = true;
record['field_6']['disabled'] = true;
record['field_7']['disabled'] = true;
record['field_8']['disabled'] = true;
record['field_9']['disabled'] = true;
break;
case "選択肢C":
case "選択肢D":
case "選択肢E":
if ( record['field_4']['value'] === "" ){
record['field_4']['error'] = "必須項目!";
}
if ( record['field_5']['value'] === "" ){
record['field_5']['error'] = "必須項目!";
}
if ( record['field_6']['value'] === "" ){
record['field_6']['error'] = "必須項目!";
}
if ( record['field_7']['value'] === "" ){
record['field_7']['error'] = "必須項目!";
}
if ( record['field_8']['value'] === "" ){
record['field_8']['error'] = "必須項目!";
}
if ( record['field_9']['value'] === "" ){
record['field_9']['error'] = "必須項目!";
}
record['field_1']['disabled'] = true;
record['field_2']['disabled'] = true;
record['field_3']['disabled'] = true;
break;
case "選択肢F":
record['field_1']['disabled'] = true;
record['field_2']['disabled'] = true;
record['field_3']['disabled'] = true;
record['field_4']['disabled'] = true;
record['field_5']['disabled'] = true;
record['field_6']['disabled'] = true;
record['field_7']['disabled'] = true;
record['field_8']['disabled'] = true;
record['field_9']['disabled'] = true;
break;
default:
record['field_1']['disabled'] = false;
record['field_2']['disabled'] = false;
record['field_3']['disabled'] = false;
record['field_4']['disabled'] = false;
record['field_5']['disabled'] = false;
record['field_6']['disabled'] = false;
record['field_7']['disabled'] = false;
record['field_8']['disabled'] = false;
record['field_9']['disabled'] = false;
break;
}
return event;
}
そもそも動いてくれず、ほぼ内容は同じですが、
上記内容をドロップダウンの値を変更した際に~ではなく、
レコードの保存時~に変更して作ってみましたが、
こちらも上手くいかず。
どこが間違っているのかもわからなくなってしまい、
投稿させていただきました。