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

Java Subtraction for Positive # only

New Here ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

I am trying to add two fields for a sum in a third field, but only if the 2nd field is a positive number. The two fields I am adding are: “Total Hotel Expenses” and “Total ASP Less Per Diem” to come up with a total in the field “Total Expenses Due”. But if the “Total ASP Less Per Diem” is a negative number then I want it to add it as 0. Any assistance would be greatly appreciated…Thanks Patrick

TOPICS
Acrobat SDK and JavaScript , Windows

Views

201

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
LEGEND ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

LATEST

You could do something like this as the custom calculation script for the Total Expenses Due field:

// Custom calculation script

(function () {

    // Get the input field values, as numbers

    var v1 = +getField("Total Hotel Expenses").value;

    var v2 = +getField("Total ASP Less Per Diem").value;

   if (v2 < 0) v2 = 0;

    // Set this field's value to the sum

    event.value = v1 + v2;

})();

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