Calculate field value on save
Displaying a preferred unit to end users, but always save a standardised unit
Use this pattern when users enter values in one unit, but the table should always store a standard unit.
Build the form
- Add a create form for the table
- Add an options picker for the unit field
- Use custom options for the supported units
Calculate the value
- Add an
On changeaction to the unit picker - Read the previous unit and the new unit
- Recalculate the value with
Update Field Value
Save the row
- Add a save button
- Save the form data
- Multiply the entered value by the selected unit factor before saving
- Clear the form after saving
Why this works
The user sees the unit they selected, but the table always stores one consistent value.
Workspace export
Downloads may take a few seconds.
Updated 4 months ago
Did this page help you?