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

Multiply sum of several number fields with another value when checkbox on

Community Beginner ,
Mar 04, 2024 Mar 04, 2024

I have a receipt form with many number fields. I need a field "Card Fee" to contain the product of 0.05 by the sum of four other fields when the "Charge" checkbox is ticked.  Many times only one of these summed fields ("Parts") will contain a value, which is the sum of several other fields, if that matters.

The breakdown of the equation is:

("Core Due" + "Parts"  + "Service" + "Shipping") * 0.05 = "Card Fee"

TOPICS
How to , PDF
713
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 04, 2024 Mar 04, 2024

Use this as custom calculation script of "Card Fee" field:

var f1 = Number(this.getField("Core Due").valueAsString);
var f2 = Number(this.getField("Parts").valueAsString);
var f3 = Number(this.getField("Service").valueAsString);
var f4 = Number(this.getField("Shipping").valueAsString);
var check = this.getField("Charge").valueAsString;
var total = (f1+f2+f3+f4)*0.05;

event.value = (check === "Off") ? "" : total;

View solution in original post

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 ,
Mar 04, 2024 Mar 04, 2024

Use this as custom calculation script of "Card Fee" field:

var f1 = Number(this.getField("Core Due").valueAsString);
var f2 = Number(this.getField("Parts").valueAsString);
var f3 = Number(this.getField("Service").valueAsString);
var f4 = Number(this.getField("Shipping").valueAsString);
var check = this.getField("Charge").valueAsString;
var total = (f1+f2+f3+f4)*0.05;

event.value = (check === "Off") ? "" : total;
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 ,
Jun 14, 2024 Jun 14, 2024

I copied and pasted and realized my Shipping field is actually named "Total Shipping." I added that to the script, but it still didn't work 😞

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 ,
Jun 14, 2024 Jun 14, 2024
LATEST

Thank you! I was entering as a custom validation script lol, once I realized my error, your script worked perfect.

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