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

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

Community Beginner ,
Nov 02, 2021 Nov 02, 2021

Copy link to clipboard

Copied

Cal Form.jpg

TOPICS
Acrobat SDK and JavaScript

Views

93

Likes

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

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

 

 

Likes

Translate

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

Copy link to clipboard

Copied

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...

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

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

 

 

Likes

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

Copy link to clipboard

Copied

LATEST

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

Likes

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