Hi @TCChero, and welcome to the SeaTable forum!
First of all, thank you for your effort to present your case as clearly as possible, I really appreciate that! However, I’m afraid I quite didn’t understand the whole process as I wasn’t able to reproduce your problem
. In my case, I don’t get 0 but a #DIV/0! error in the Recipe Cost field of the Recipe List table.
Here is the global base structure I set up based on your description:
Please note that this screenshot comes from the table relationships plugin, and I’d really like to have the same from your base.
Here is why I get this error, which is something that doesn’t seem to work in your process:
- In Ingredients table, for WIP ingredients,
Net cost per base unitis calculated from{WIP Recipe.Total cost} - In WIP Recipes table,
Total costis computed (rollup/SUM) fromLine costin Recipe ingredients table - In Recipe ingredients table,
Line costis related to{Ingredient.Net cost per base unit}
=> There is no “entry point”
Scripting
About scripting, please have a look at the recently reworked scripting documentation in SeaTable’s developer documentation. You’ll find both simple examples and exhaustive reference for each function. Here is a very short Getting started however:
- JavaScript:
baseshould be defined. Do you get the error trying a simple code such as this one?
const tables = base.getTables();
output.text(tables.length);
- Python: you need to import the
seatable_apimodule and to authenticate to your base in order to be able to interact with the base. The equivalent to the above JavaScript script will be:
from seatable_api import Base, context
base = Base(context.api_token,context.server_url)
base.auth()
tables = base.list_tables()
print(len(tables))
Base structure
I struggle understand your base structure. As far as I understand it (and as I already said, I probably missed something!), here is the main process:
- For “final” recipes, you calculate the recipe cost from the sum of single ingredient cost multiplied by its quantity
- For WIP recipes, I don’t really understand how you want to the calculation to be processed: you have the global recipe cost, each ingredient’s quantity and you want to calculate each ingredient cost right? If it’s the case, your
Total Costin WIP Recipes table should be manually defined and not computed (rollup/SUM) from ingredients. However, you won’t be able to calculate properly each ingredient cost if you have several ingredients: you have one single equation that looks like global cost = ingredient1.cost * ingredient1.quantity + ingredient2.cost * ingredient2.quantity + … but you’re trying to find out several variables (ingredient1.cost, ingredient2.cost, …) which is not possible.
Please clarify the process for WIP recipes (what/how are you trying to calculate?) and share with us a screenshot from the table relationships plugin, it may help to better understand your problem.
Bests,
Benjamin
