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

Need To Blank Calculated Date Field If Another Date Field Has No Date Entered

Community Beginner ,
Nov 02, 2021 Nov 02, 2021

Cal Form.jpgexpand image

TOPICS
Acrobat SDK and JavaScript
1.0K
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

correct answers 1 Correct answer

Community Expert , Nov 02, 2021 Nov 02, 2021

OK, I see now that you did do it, but incorrectly. Use this:

 

var s = this.getField("DatePerformed").valueAsString;
if (s=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy", s);
	d.setMonth(d.getMonth() + 3);
	event.value = util.printd("mm/dd/yyyy", d);
}

 

 

Translate
Community Expert ,
Nov 02, 2021 Nov 02, 2021

You need to add another condition that checks if the value of the first field is empty, as that would be converted to the current date if you use scand on it.

If you post your code as text it would be easier to help you out with this...

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 Beginner ,
Nov 02, 2021 Nov 02, 2021

Ooops...Sorry about that... Here it is

 

var d = util.scand("mm/dd/yyyy",this.getField("DatePerformed").valueAsString);

if (this.getField("DatePerformed").valueAsString="") event.value = "";

else d.setMonth(d.getMonth() + 3);

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
Community Expert ,
Nov 02, 2021 Nov 02, 2021

OK, I see now that you did do it, but incorrectly. Use this:

 

var s = this.getField("DatePerformed").valueAsString;
if (s=="") event.value = "";
else {
	var d = util.scand("mm/dd/yyyy", s);
	d.setMonth(d.getMonth() + 3);
	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
Community Beginner ,
Nov 02, 2021 Nov 02, 2021
LATEST

Awesome! Works like a champ. Thank you so much! 

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