この会話は、活動がないためロックされています。新しい投稿を作成してください。
この会話は、活動がないためロックされています。新しい投稿を作成してください。
I have a date field named dateStart and a date field named dateEnd.
The dateEnd field needs to automatically fill with the date that is 90 days after the dateStart field, which the user enters.
I've tried different options and never get it right. Can someone please provide a sample of the code to accomplish this?
解決済! 解決策の投稿を見る。
表示
返信
いいね!の合計
From the dateEnd field in your form, remove validation pattern and make the field protected/readOnly instead of calculated.
I have modified the script as per your date fields format:
var dtStart = util.scand("yy-mm-dd", this.rawValue);
var dtEnd = new Date(dtStart.getFullYear(), dtStart.getMonth(), dtStart.getDate() +90,0,0,0,0);
var yy = dtEnd.getFullYear().toString();
var mm = (dtEnd.getMonth()+1).toString();
var dd = dtEnd.getDate().toString();
dateEnd.rawValue = (mm[1]?mm:"0"+mm[0]) + "/" +(dd[1]?dd:"0"+dd[0]) + "/" + yy[2]+ yy[3];
Add below code snippet in the start Date exit event:
var startDate= util.scand("yyyy-mm-dd", this.rawValue);
var endDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() +90, 0, 0, 0, 0);
var yyyy = endDate.getFullYear().toString();
var mm = (endDate.getMonth()+1).toString();
var dd = endDate.getDate().toString();
endDateField.rawValue = yyyy + "-" + (mm[1]?mm:"0"+mm[0]) + "-" +(dd[1]?dd:"0"+dd[0]);
From the dateEnd field in your form, remove validation pattern and make the field protected/readOnly instead of calculated.
I have modified the script as per your date fields format:
var dtStart = util.scand("yy-mm-dd", this.rawValue);
var dtEnd = new Date(dtStart.getFullYear(), dtStart.getMonth(), dtStart.getDate() +90,0,0,0,0);
var yy = dtEnd.getFullYear().toString();
var mm = (dtEnd.getMonth()+1).toString();
var dd = dtEnd.getDate().toString();
dateEnd.rawValue = (mm[1]?mm:"0"+mm[0]) + "/" +(dd[1]?dd:"0"+dd[0]) + "/" + yy[2]+ yy[3];
Perfection! Thank you so much!! This issue is solved!