Skip to main content
Participant
August 9, 2023
Question

Need help auto-populating dates.

  • August 9, 2023
  • 1 reply
  • 212 views

Greetings from Alaska,

I have a form with dates that I have to fill out. On every anniversary the employee moves to a higher tier:

Is there a script that I can use to autofill the dates?

Thank you for your help,

Martin

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 9, 2023

So you want to enter the first field, and have the rest of them fill in automatically?

If so, it's just a matter of adding 1 year, or 1 day, to each one.

The basic code would be something like this (as the custom validation script of the first field):

 

if (event.value) {
	var d = util.scand("mm/dd/yyyy", event.value);
	d.setFullYear(d.getFullYear()+1);
	this.getField("Expiration1").value = util.printd("mm/dd/yyyy", d);
	d.setDate(d.getDate()+1);
	this.getField("Effective2").value = util.printd("mm/dd/yyyy", d);
	d.setFullYear(d.getFullYear()+1);
	this.getField("Expiration2").value = util.printd("mm/dd/yyyy", d);
	// etc.	
}