# 指定した文字列フィールドのデータが変更された時、ドロップダウン＆日付フィールドに値を入れ込みたい

**URL:** <https://community.cybozu.dev/t/topic/6072>\
**Category:** kintone 開発相談\
**Created:** [2022 年 6 月 16 日午前 6:45 UTC](https://community.cybozu.dev/t/topic/6072 "2022-06-16T06:45:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account2929](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@Legacy\_Account2929](https://community.cybozu.dev/u/Legacy_Account2929)\
**Post date:** [2022 年 6 月 16 日午前 6:45 UTC](https://community.cybozu.dev/t/topic/6072/1 "2022-06-16T06:45:16Z")

</div>

回答完了画面に移動前に指定した文字列フィールドのデータを変更したときに、ドロップダウン＆日付フィールドの値を指定したデータに変更したいです。

&nbsp;

(function() {

&nbsp; &nbsp; “use strict”;

&nbsp; &nbsp; fb.events.form.submit = [function (state) {

&nbsp; &nbsp; &nbsp; &nbsp; var mailAdress = fb.getElementByCode(‘ご入力者様のメールアドレス’); //文字列フィールド

&nbsp; &nbsp; &nbsp; &nbsp; var mailPermission = fb.getElementByCode(‘メール送付パーミッション’); //ドロップダウンフィールド 選択項目；「あり」「なし」

&nbsp; &nbsp; &nbsp; &nbsp; var permissionDate = fb.getElementByCode(‘メール送付パーミッション許可日’); //日付フィールド

&nbsp; &nbsp; &nbsp; &nbsp; var now = new Date();

&nbsp; &nbsp; &nbsp; &nbsp; var Year = now.getFullYear();

&nbsp; &nbsp; &nbsp; &nbsp; var Month = now.getMonth()+1;

&nbsp; &nbsp; &nbsp; &nbsp; var Day = now.getDate();

&nbsp; &nbsp; &nbsp; &nbsp; if(mailAdress != “”){

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mailPermission.getElementsByTagName(‘input’)[0].value = ‘あり’;&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; permissionDate.getElementsByTagName(‘input’)[0].value = Year+“-”+Month+“-”+Day;

&nbsp; &nbsp; &nbsp; &nbsp; }

&nbsp; &nbsp; &nbsp; return state;

&nbsp; &nbsp; }];

&nbsp; })();

&nbsp;

上記のコードで回答画面推移前に

メール送付パーミッション【ドロップダウン】 → あり  
'メール送付パーミッション’許可日【日付】 → 現在日時

のようにデータを入力できているのですが、kintoneアプリへ値が反映されておりません。  
【ドロップダウン】【日付】の選択肢項目を取得し、取得したデータを入れ込んであげることは可能なのでしょうか？

---

<div class="post-metadata">

**Author:** ![Legacy\_Account2229](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Legacy\_Account2229](https://community.cybozu.dev/u/Legacy_Account2229)\
**Post date:** [2022 年 6 月 18 日午前 2:43 UTC](https://community.cybozu.dev/t/topic/6072/2 "2022-06-18T02:43:56Z")

</div>

minamiさん

こんにちは。

&nbsp;

フォームブリッジでは、フィールドへの値の格納は以下のように記述します。

```
state.record.フィールドコード.value = '値';

```

&nbsp;

```
if (state.record.ご入力者様のメールアドレス.value != "") {
  state.record.メール送付パーミッション.value = 'あり';
state.record.メール送付パーミッション許可日.value = Year + "-" + Month + "-" + Day;
}

```

inputのvalueに指定することで見た目では値が入ったように見えますが、kintoneレコードに反映させるにはstate.recordに格納する必要があります。

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/cybozu/original/1X/d5c841c3c5a6cb66eed514001c1b45147c9e1f4f.png) [@system](https://community.cybozu.dev/u/system)\
**Post date:** [2024 年 9 月 25 日午前 6:48 UTC](https://community.cybozu.dev/t/topic/6072/3 "2024-09-25T06:48:42Z")

</div>

クローズされました: 2024 年 9 月 25 日午前 6:48 UTC

このトピックはベストアンサーに選ばれた返信から 3 日が経過したので自動的にクローズされました。新たに返信することはできません。
