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

If else if statement for dummies using Custom calculation script

New Here ,
Nov 30, 2021 Nov 30, 2021

Copy link to clipboard

Copied

I am attempting to create a reimbursement form, I have a field called Meal Row.0 that is a drop down. The options are Breakfast, Lunch, Dinner.  The next field  Allowance.0, I need the allowance to populate. So if Meal Row.0 is Breakfast, the allowance needs to be 10.00, Lunch is 15.00, and Dinner is 25.00.  I have read over many different posts, but I get the SyntaxError: missing : before statement: at line 2. Below is a screenshot of what I have so far. 

Eventually, I will be creating a calculation in a seperate field of the total reimburseable amount based on the allowance * the number of people that were paid for on the receipt. (If I buy your lunch then the allowable amount is $30 and if I spent 29, then I would be reimbursed 29. But If I spent 33.00 I would only get $30.)

Any help would be appreciated. 

 

Kitty22014564gsz1_0-1638290706191.png

 

TOPICS
JavaScript , PDF forms

Views

1.4K

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 ,
Nov 30, 2021 Nov 30, 2021

Copy link to clipboard

Copied

Give your options in dropdown export value to be amount you want and then in "Allowance.0" as custom calculation script use:

event.value = this.getField("Meal Row.0").value;

 

tempsnip.png

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
New Here ,
Nov 30, 2021 Nov 30, 2021

Copy link to clipboard

Copied

Thanks, 

That gor rid of the Syntax errors, but when I tested it, the value did not populate.

 

Kitty22014564gsz1_0-1638299007639.png

 

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 ,
Nov 30, 2021 Nov 30, 2021

Copy link to clipboard

Copied

If you apply export values that will be the value of the field when selected, not the display value, so you can just apply it directly in your code to 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
New Here ,
Nov 30, 2021 Nov 30, 2021

Copy link to clipboard

Copied

LATEST

Ok thank you! I got that to work. I was able to do the next two calculations, but now I am to have it if payment method is Personal Account (export value 1) then Allowable amountrow1, otherwise 0. Allowable amountrow1 has a calculated value. 

My intention here is that if the Payment method is Personal Account, I want the Allowable amount to be displayed. This is a calculation based on the amount spent vs the allowable amount. 

In my test I enter 25 as the amount. then th erow1max1 calculate the max amount allowed based on the number of people * the allowance. the Allowable amount is if the  amount is less than the max then the amount is displayed. if the max amount is lower the amount, then the max is diplayed.  

Kitty22014564gsz1_1-1638308421790.png

 

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