Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to auto-populate fields based on entry in another field...

Contributor ,
Apr 17, 2022 Apr 17, 2022

Hi!

 

I have a field for "Week Ending Date" and then I have individual fields for each date of that week.

 

I'd like those individual date fields to auto-populate the correct date when the "Week Ending Date" field is filled in.

 

Is that possible?

 

Thank you so much!

TOPICS
How to , PDF forms
994
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Apr 17, 2022 Apr 17, 2022

Yes, this is possible using a script.

Here's the basic code to do it (to be used as the calculation script for the field that needs to show the day before that date, for example):

 

var s = this.getField("WeekEndingDate").valueAsString;
if (s=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy", s);
	d.setDate(d.getDate()-1);
	event.value = util.printd("mm/dd/yyyy", d);
}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2022 Apr 17, 2022

Yes, this is possible using a script.

Here's the basic code to do it (to be used as the calculation script for the field that needs to show the day before that date, for example):

 

var s = this.getField("WeekEndingDate").valueAsString;
if (s=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy", s);
	d.setDate(d.getDate()-1);
	event.value = util.printd("mm/dd/yyyy", d);
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 18, 2022 Apr 18, 2022

@try67 

Thank you!! You are amazing!! 🙂

 

By reading and following through your script I even managed to set it so that it displays only the date "dd" in the individual fields.

 

Thank you again so much!!

 

Have a great day!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2022 Apr 18, 2022

Great, and you're very welcome!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 21, 2023 Nov 21, 2023
LATEST

Wanted to say thank you for this. I needed something similar and adjusted accordingly for my usage. Works great. Couldnt have done it without this getting me 90% there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines