I’m building an app to calculate the manufacturing costs of some products. I’ve run into an issue with setting default values in my “Crear cotizacion” screen.
Here’s my current setup:
A “Products” table containing details for many different products (e.g., name, net weight, load weight, color).
A “Quote” table with a single row that holds the data for the quote being generated on the “Crear cotizacion” screen.
On the “Crear cotizacion” screen, I have several fields. Some are for user input and others are calculated. For instance:
peso_pieza (Part Weight): A user-input field. peso_colada (Load Weight): A user-input field. peso_total (Total Weight): A calculated field that is the sum of peso_pieza and peso_colada.
I also have a choice component that allows the user to select a product from the “Products” table.
My goal is to have the peso_pieza and peso_colada fields automatically populate with the default weight values from the “Products” table whenever a product is selected. The user should still be able to modify these default values if needed.
Also I’m looking for a way to dynamically update the default values in the peso_pieza and peso_colada entry fields based on the product chosen from the dropdown menu. I’ve searched the documentation and community forums but haven’t found a solution.
Selecting an item in a choice component will not execute an action to set other values. You can dynamically control the filter for those other choice components, but that’s about it unless you have a button or something that the user clicks after each choice.
It may be possible if you create a custom AI component to simulates the choice component and allows it to run an action that will set subsequent values.
Add fields for producto, peso_pieza and peso_colada (basic columns).
Use relations & lookup to pull back peso_colada and peso_pieza for the chosen product.
Add an AI component, connect the lookup fields and the basic column fields for peso_pieza and peso_colada. Tell it to write to the basic columns whenever the lookup fields are changed. Also tell it to not generate anything on the front end and set the height to 0.
So based on what you guys wrote. I finally made it work.
I created a relation and a Single value column for each field that looks for the record on the Products table, which I used for the default of the entry component. I created a button under the Products dropdown that runs a workflow that updates the fields based on the selected option. Might not be elegant but it does the trick.