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

Excel to Javascript Formula Help

New Here ,
May 08, 2018 May 08, 2018

Copy link to clipboard

Copied

I'm creating an Adobe Acrobat Pro DC form using an excel spreadsheet as a template.  My excel formula is IF(Productivity=0,,Total/Productivity*8)

I can't get the "if else" formula to work in Javascript.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

245

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
Engaged ,
May 09, 2018 May 09, 2018

Copy link to clipboard

Copied

LATEST

Literraly, it would be:

if (Productivity == 0) event.value = ""

else event.value = Total / Productivity * 8

and you would copy this script in the calculate tab of the field you want the calculation to take place.  This is all providing that you assigned a value to the variables named Total and Productivity.

So functionally, since an evaluation of your "if statement" to TRUE doesn't do anything, you should only evaluate the FALSE eventuallity:

if (Productivity != 0) event.value = Total / Productivity * 8

There is no need for an "else statement".  The complete code would be this:

var Total = this.getField("Name the field where that value is found").value

var Productivity = this.getField("Name the field where that value is found").value

if (Productivity != 0) event.value =Total / Productivity * 8

If it is not clear, come back with the name of your fields.

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