Skip to main content
New Participant
November 30, 2021
Question

If else if statement for dummies using Custom calculation script

  • November 30, 2021
  • 1 reply
  • 1933 views

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. 

 

 

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
November 30, 2021

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;

 

New Participant
November 30, 2021

Thanks, 

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

 

 

try67
Community Expert
November 30, 2021

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.