Skip to main content
Participant
August 26, 2020
Question

Creating Expense Form with either or fields

  • August 26, 2020
  • 2 replies
  • 369 views

I want each line to either have mileage or an expense amount, but not both.

I have the total for the line to calculate mileage value if there is an amount in the mileage column or put in the amount spent, but I want to limit the user to only putting a value in one column or the other.

Columns in form are:

Date, Description, Miles, Amount, GL Account, Total

Miles and Account are formatted as numbers.

My total column calculation if then script works but does not prevent using both.

 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
August 26, 2020

The way to achieve that is to have each field reset the value of the other when filled. Let's say they are called Miles1 and Amout1. As the custom validation script of Miles1 enter:

if (event.value) this.resetForm(["Amount1"]);

And under Amount1 enter:

if (event.value) this.resetForm(["Miles1"]);

Inspiring
August 26, 2020

Can you share file or photo of your fields?