新規投稿
フォローする

チェックボックスの集計(項目を増やす)

https://developer.cybozu.io/hc/ja/community/posts/115009112986-%E3%83%A9%E3%82%B8%E3%82%AA%E3%83%9C%E3%82%BF%E3%83%B3-%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%83%9C%E3%83%83%E3%82%AF%E3%82%B9%E3%82%92%E5%88%A9%E7%94%A8%E3%81%97%E3%81%A6%E6%95%B0%E5%80%A4%E3%82%AB%E3%82%A6%E3%83%B3%E3%83%88%E3%81%99%E3%82%8B 

を参考に使用し、うまく動作できていましたが

11項目を足そうとしたらエラーがで動作しなくなります。

どなたか理由をお教えいただけませんでしょうか?

 

(function() {
"use strict";

var fields = [
{ from: 'FCheck', to: 'FPoint' },
{ from: 'FCheck2', to: 'FPoint2' },
{ from: 'FCheck3', to: 'FPoint3' },
{ from: 'FCheck4', to: 'FPoint4' },
{ from: 'FCheck5', to: 'FPoint5' },
{ from: 'FCheck6', to: 'FPoint6' },
{ from: 'FCheck7', to: 'FPoint7' },
{ from: 'FCheck8', to: 'FPoint8' },
{ from: 'FCheck9', to: 'FPoint9' },
{ from: 'FCheck10', to: 'FPoint10' }
];
kintone.events.on(["app.record.edit.show", "app.record.create.show"], function(event) {
var record = event.record;
fields.forEach(function(field) {
record[field.to].disabled = true;

})
return event;

});

var events = ["app.record.edit.show", "app.record.create.show"];
fields.forEach(function(field) {
events.push("app.record.edit.change." + field.from);
events.push("app.record.create.change." + field.from);

})

kintone.events.on(events, function(event) {
var record = event.record;
fields.forEach(function(field) {
record[field.to].value = record[field.from].value.length;
})
return event;
});
})();

0

4件のコメント

Avatar
江田篤史

大初心者様

お世話になっております.
トヨクモの江田と申します.

エラーメッセージを教えていただけますか?

0
Avatar
大初心者

ありがとうございます。

 

このように出ています。

先ほど添付したものは、足す前で

今はこちらになっています。

この状態だとエラー表示になります。

(function() {
"use strict";

var fields = [
{ from: 'FCheck', to: 'FPoint' },
{ from: 'FCheck2', to: 'FPoint2' },
{ from: 'FCheck3', to: 'FPoint3' },
{ from: 'FCheck4', to: 'FPoint4' },
{ from: 'FCheck5', to: 'FPoint5' },
{ from: 'FCheck6', to: 'FPoint6' },
{ from: 'FCheck7', to: 'FPoint7' },
{ from: 'FCheck8', to: 'FPoint8' },
{ from: 'FCheck9', to: 'FPoint9' },
{ from: 'FCheck10', to: 'FPoint10' }
{ from: 'FCheck11', to: 'FPoint11' }
{ from: 'FCheck12', to: 'FPoint12' }
];
kintone.events.on(["app.record.edit.show", "app.record.create.show"], function(event) {
var record = event.record;
fields.forEach(function(field) {
record[field.to].disabled = true;

})
return event;

});

var events = ["app.record.edit.show", "app.record.create.show"];
fields.forEach(function(field) {
events.push("app.record.edit.change." + field.from);
events.push("app.record.create.change." + field.from);

})

kintone.events.on(events, function(event) {
var record = event.record;
fields.forEach(function(field) {
record[field.to].value = record[field.from].value.length;
})
return event;
});
})();

0
Avatar
江田篤史

大初心者様

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

10番目と11番目の要素の後のカンマが不足しています.

var fields = [
  { from: 'FCheck', to: 'FPoint' },
  { from: 'FCheck2', to: 'FPoint2' },
  { from: 'FCheck3', to: 'FPoint3' },
  { from: 'FCheck4', to: 'FPoint4' },
  { from: 'FCheck5', to: 'FPoint5' },
  { from: 'FCheck6', to: 'FPoint6' },
  { from: 'FCheck7', to: 'FPoint7' },
  { from: 'FCheck8', to: 'FPoint8' },
  { from: 'FCheck9', to: 'FPoint9' },
  { from: 'FCheck10', to: 'FPoint10' }
  { from: 'FCheck11', to: 'FPoint11' }
  { from: 'FCheck12', to: 'FPoint12' }
];

var fields = [
  { from: 'FCheck', to: 'FPoint' },
  { from: 'FCheck2', to: 'FPoint2' },
  { from: 'FCheck3', to: 'FPoint3' },
  { from: 'FCheck4', to: 'FPoint4' },
  { from: 'FCheck5', to: 'FPoint5' },
  { from: 'FCheck6', to: 'FPoint6' },
  { from: 'FCheck7', to: 'FPoint7' },
  { from: 'FCheck8', to: 'FPoint8' },
  { from: 'FCheck9', to: 'FPoint9' },
  { from: 'FCheck10', to: 'FPoint10' },
  { from: 'FCheck11', to: 'FPoint11' },
  { from: 'FCheck12', to: 'FPoint12' }
];
0
Avatar
大初心者

そんなことだったんですね💦

修正後ちゃんと動作しています!

丁寧に教えていただき、ありがとうございました。

 

1
ログインしてコメントを残してください。