Copy link to clipboard
Copied
I have a form that requires 7 day history from date of application. The user inputs the application date. I then have 7 separate fields that should auto calculate the past 7 days from the user input. For example: user input = 06/07/2018
Prior 7 | Prior 6 | Prior 5 | Prior 4 | Prior 3 | Prior 2 | Prior 1 |
---|---|---|---|---|---|---|
05/31/2018 | 06/01/2018 | 06/02/2018 | 06/03/2018 | 06/04/2018 | 06/05/2018 | 06/06/2018 |
With the dates in the table above being auto-calculated in 7 separate fields. Let me know if I'm not making any sense. Also, here's something that I found to try and adapt to what I need, but my coding knowledge is small and not in Java at all haha so any help is appreciated.
var dateString = this.getField("Date of Application").value;
if (dateString=="") event.value = "";
else {
var d = util.scand("mm/dd/yyyy", dateString);
d.setDate(d.getDate()-7);
event.value = util.printd("mm/dd/yyyy", d);
}
Thanks.
Copy link to clipboard
Copied
The code you found is correct, for the last day in the series. What happens when you place it as the custom calculation script of that field?
Copy link to clipboard
Copied
When I put it in the prior 7 field nothing happens. Am I supposed to do something special to trigger the script?
Edit: I was putting the script in the validation field. I put it in the calculation field and it worked haha. I feel dumb, but thank you for talking it out with me.
Copy link to clipboard
Copied
🙂 Not a problem!