Menu

How do I set a default value on a lookup field?

0 votes

If I have a table called Orders, with a lookup table called "Order Status" which has values like Draft, In Progress, Complete, etc (since it seems like you can't create dropdowns in dbfront, only lookups from another table with the values?) how do I set the default value? Like if I want to create a new Order, how can I have the Status field default to "Draft"?

in Customization by (120 points)

1 Answer

0 votes

All column default values are set at the database. This includes default lookup fields (foreign keys).

For a lookup field you would need to specify the unique key value used by the relationship to the lookup table. For example, if your "Order Status" table was joined on the values like "Draft", then you would specify "Draft". If the lookup relationship used a numeric key then the default value for "Draft" might be 0.

Some databases allow for calculated column defaults. All databases allow you to use a table trigger to calculate an appropriate default.

Column defaults are preferable because dbFront will load and show the default value to the user when a new record is started.

Note: To see why dbFront is designed to use lookup tables to support dropdowns, see: Custom Dropdown Request

by (44.5k points)
Welcome to the dbFront Q&A site, where you can ask questions and receive answers from other members of the community.
 | Minimalist Answer Theme by Digitizor Media
 |
Powered by Question2Answer
...