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

Calculate based on the value of another field and leave blank if other field is blank

Explorer ,
Jul 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

I am looking for some help with form field calculations .

 1. I need to multiply "TGAI" * 0.03 , but if  "MedicalExpenses" is empty then leave return the value of "0". 

  •  this field, when calculated needs to return a negative value 

2. If  "HPW" AND "WPY" are blank then leave cell blank if "HPW" AND "WPY" have values then multiply "HW" * "HPY"

 

Thank you for any help you can provide. 

TOPICS
How to , JavaScript , PDF , PDF forms

Views

698

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
2 ACCEPTED SOLUTIONS
Community Expert ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

A couple of issues:

1)  You had a validation script AND a calculation script in the field.  Remove the validation script.

2)  You missed the ! in my script, which changes the statement to a value vs no value.  Here's the calculation script again (copy and paste it).

 

if(!this.getField("MedicalDeduction").value)
{event.value=0}
else
{event.value=this.getField("Calc_TotalGAI").value * .03 * -1}

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 ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

if(!this.getField("GMI.0").value)
{event.value=25}
else
{event.value=this.getField("Calc_TotalMonthlyPayment").value-this.getField("Utilities").value}

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 ,
Jul 22, 2024 Jul 22, 2024

Copy link to clipboard

Copied

1. 

if(!this.getField("MedicalExpense").value)

{event.value=0}

else

{event.value=this.getField("TGAI").value * .03 * -1}

2.

if(this.getField("HPW").value && this.getField("WPY").value)

{event.value=this.getField("HPW").value * this.getField("WPY").value}

else

{event.value=""}

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
Explorer ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Good morning and thank you for your response . the script provided for #1 does not work , but #2 does . 

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 ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

What result are you getting.  Do you have errors in the console?

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
Explorer ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Thats the odd thing, im not getting any error messages , its just not calculating . 

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 ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Can you upload your document?

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
Explorer ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

Yes , it may look a little off as i had to scrub some of the information from the document . I left notes on the bottom in regard to the issue . 

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 ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

A couple of issues:

1)  You had a validation script AND a calculation script in the field.  Remove the validation script.

2)  You missed the ! in my script, which changes the statement to a value vs no value.  Here's the calculation script again (copy and paste it).

 

if(!this.getField("MedicalDeduction").value)
{event.value=0}
else
{event.value=this.getField("Calc_TotalGAI").value * .03 * -1}

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
Explorer ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

That worked , thank you so much , now i just have one more issue on this form and im done with it . 

 if you dont mind taking a look when you get a chance i would really appriciate it .

 

I have left notes on the form and included the entire worksheet this time for your reference . 

 

Again , thank you for your time 

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 ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

if(!this.getField("GMI.0").value)
{event.value=25}
else
{event.value=this.getField("Calc_TotalMonthlyPayment").value-this.getField("Utilities").value}

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
Explorer ,
Jul 23, 2024 Jul 23, 2024

Copy link to clipboard

Copied

LATEST

Thank you so much for your help !

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