In a google-apps-script, I have an html form with two date inputs. I want to set the default values to be the prior week of the current day.
I cannot get the following scripts to work. Can anyone point out what I am doing wrong?
I am getting a "Object does not allow properties to be added or changed" error.
Code.gs:
function pickDates() {
var d = new Date();
var e = new Date();
d.setDate((d.getDate() - d.getDay() % 7) - 7);
e.setDate(e.getDate() - (e.getDay() + 1) % 7);
d = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
e = e.getFullYear() + '-' + (e.getMonth() + 1) + '-' + e.getDate();
var htmlB = HtmlService.createHtmlOutputFromFile('Pick Dates').setWidth(200).setHeight(200);
htmlB.d = d;
htmlB.e = e;
SpreadsheetApp.getUi().showModalDialog(htmlB, 'Select Dates');
}
Pick Dates.html:
Start Date
End Date
document.getElementById('start').value = d;
document.getElementById('end').value = e;