Can I set up a formula field so that a user can overwrite the information when in edit mode?

  • 1
  • 1
  • Question
  • Updated 2 years ago
  • Answered
Can I set up a formula field so that a user can overwrite the information when in edit mode? Another approach would be to set the default value for one field to equal the value of another field.  Is that possible?
Photo of Mary

Mary

  • 240 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
Yes.  A good use case for this, and the example I'm going to use, is when you have an Item price, but want to have the option to override the list price.

[My List Price] is a field coming from a parent table, or an items table.
[Price Override] is a field that can change the value
[Price] will be the formula field that takes the list price, or take the override price.

[Price] formula would be:

If( IsNull( [Price Override] ), [My List Price], [Price Override])

If you are using text fields, the similar, but use the sign ="" rather than the null:

If( [My Override Text]="", [My Default Text], [My Override Text])
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,814 Points 50k badge 2x thumb
.. just a tip.  If you are checking a numeric field to be blank with IsNull, be sure to set that numeric field to not treat blank as null.  There is a field property checkbox for that.
Photo of Mary

Mary

  • 240 Points 100 badge 2x thumb
Thanks.  That is the way I have been doing it.  Was just wondering if there was a way using only one field.
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
Can you describe your set up a little more?  as far as tables and fields you are using.

You could possibly modify the button to write the value to the field when you first load the page, but give you the option to override it in the same field.  But this depends on your set up, and where the data is coming from.
Photo of Mary

Mary

  • 240 Points 100 badge 2x thumb
Here is my specific situation...
I have a stipend field and a benefits field.  Both are currency.
Once I enter the stipend amount, I want the benefits field to be auto-populated as 25% of the stipend.  This is our estimate.  
Once the stipend has been processed and paid, I will know the actual benefits dollar amount.
I would like to overwrite the auto-populated benefit amount with the exact benefits amount in the same field.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
This can be done with a formula which does that 25% calculation and a form rule

When [Benefits] is blank
Change [Benefits] to the value in the field [Stipend arstinsted]

You will have to have the [Benefits Estimated] field on the form, even if it's in a hidden section.

You can experiment with that rule or else a rule based on
"when the record is saved"
Photo of Mary

Mary

  • 240 Points 100 badge 2x thumb
So I tried
Estimated Benefit = Stipend * 25%

And a form rule that says
If Estimated Benefit is not blank
Then Benefit = Estimated Benefit

However, this doesn't work because Estimate Benefit is a formula field.  If I make it a non-formula field than the form rule works.
Photo of Mary

Mary

  • 240 Points 100 badge 2x thumb
On further testing, it does work for new records added but not for existing records.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,348 Points 50k badge 2x thumb
Did you uncheck the box on the form rule at the bottom so that it always fires and not just when the conditions become true?
Photo of Mary

Mary

  • 240 Points 100 badge 2x thumb
Thanks.  Had not done that.