アドバイスお願いします。
FormBrigde でフォーム入力時に
「完了希望日(compRqstDate)」というフィールドの値を自動で、
本日の日付+14日後 の値を自動で入力することはできますか?
準備として、FormBrigdeのJavascriptの設定で、jQueryと moment,js
の読み込み設定をしております。
https://js.cybozu.com/jquery/3.3.1/jquery.min.js
https://js.cybozu.com/momentjs/2.10.3/moment-with-locales.min.js
– kintoneで類似のスクリプトを実装したときのものを参考に作成 – FormBridgeでは動きませんでした
(function() {
“use strict”;
//ロケールを初期化
moment.locale(‘ja’);
var date = moment();
var now = moment(date).format(‘YYYY-MM-DD’);
console.log(now);
var increaseDates = function(originDate, dates){
var targetDay = new Date((originDate.getTime() + dates*24*60*60*1000));
return targetDay.getFullYear()+‘-’+(‘0’+(targetDay.getMonth()+1)).slice(-2)+‘-’+(‘0’+targetDay.getDate()).slice(-2);
}
fb.events.form.created = [function(state) {
state.record.compRqstDate.value = increaseDates(new Date(event.record.submitDate.value), 14);
return state;
}];
})();