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

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

Participant ,
Apr 17, 2022 Apr 17, 2022

Copy link to clipboard

Copied

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

Views

905

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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);
}

Votes

Translate

Translate

Report

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
Participant ,
Apr 18, 2022 Apr 18, 2022

Copy link to clipboard

Copied

@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!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Great, and you're very welcome!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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