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

Custom calculation script not working

New Here ,
Jul 18, 2024 Jul 18, 2024

I've tried every variation I can think of to make this work and it just isn't.

 

As seen below, the dropdown is for the customer to choose their payment method.

If they don't select one, the number in the column to the right is 0..

If they select "Wire (no fee), the number in the column to the right is 0.

If they select "Credit card (3% fee), the number in the column to the right is the Invoice Total x 3%

Screenshot 2024-07-18 at 12.03.12 PM.png

 

Here is the formula I'm using (everything is calculating correctly except the Invoice Total x 3%):

var v = this.getField("PaymentMethod").valueAsString;

if (v=="CHOOSE ONE") event.value = "0";

if (v=="Wire (no fee)") event.value = "0";

if (v=="Credit Card (3% fee)") event.value = (AmountInvoice_Total*.03);

TOPICS
PDF , PDF forms
715
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 ,
Jul 18, 2024 Jul 18, 2024

When you use AmountInvocie_Total in your last line you need to identify the field:

this.getField("AmountInvoice_Total").value

Unless you have already created a variable from that field and you're not showing it in your script.  Also:

1)  Is the calculation order correct?

2) Is "Commit select value immediately" check in the options tab of the dropdown?

If you set export values in the dropdown you don't need an 'if' statement.  Example:

event.value=this.getField("AmountInvoice_Total").value * this.getField("PaymentMethod").value;

 

 

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

When you use AmountInvocie_Total in your last line you need to identify the field:

this.getField("AmountInvoice_Total").value

Unless you have already created a variable from that field and you're not showing it in your script.  Also:

1)  Is the calculation order correct?

2) Is "Commit select value immediately" check in the options tab of the dropdown?

If you set export values in the dropdown you don't need an 'if' statement.  Example:

event.value=this.getField("AmountInvoice_Total").value * this.getField("PaymentMethod").value;

 

 

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
New Here ,
Jul 18, 2024 Jul 18, 2024
LATEST

Thank you so much I got it to 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