Hi i got the following app
this table have actual quantities for each product and thats the one that should be updated with the new quantities sum up the original + new
when i change status to 'Recibida' how i can save the quantity (table may have 1 or more records or lines for sure) in the table above? to save it in a variable and use it in another insert query. But it should happen only when status = Recibida, if status changes to other it should run another query too.
At the end, the main idea is: to save qty for each product and modify the original qty in product table so if had 10 before and after another 10, it should sum +10 = 20 for that product
thank you
You can edit the quantity in the tables using Bulk Update - assuming here that you need to write back to the database first to update the quantity?
1 Like
i first tried this to sum but i think im missing something on QTY_NEW for the first product
Note: nevermind my mistake i had to order and group by, now its summing ok
Im trying this
{{ [{ Productid: {{listaProductosCompra_Editar_Suma.data.product_id}} }] }}
but im wrong right?
tried this
{
[{
Productid: formatDataAsArray({{ listaProductosCompra_Editar_Suma.data.product_id }})
}]
error: * message:"Data must be an array."
try
{{ formatDataAsArray(listaProductosCompra_Editar_Suma.data.product_id)}}
1 Like
{
[{
id: {{ formatDataAsArray(listaProductosCompra_Editar_Suma.data.product_id)}},
quantity: {{ formatDataAsArray(listaProductosCompra_Editar_Suma.data.QTY_NEW)}}
}]
}
like this?
You are already including the product_id as the primary key so if you are editing the table use {{yourTableName.recordUpdates}} Check out the documentation
1 Like
not sure how to use this correctly, im confused
yes but what im doing wrong? whats the best approach
should i use update and existing record only? or update and existing record with primary key
i cant use recordupdates, as im not updating table itself, just showing data from query
at the end i had used a transformer instead
const categorizedData = formatDataAsArray({{ listaProductosCompra_Editar_Suma.data }}).map((row) => ({id: row.id, product_id: row.product_id, qty_available: row.QTY_NEW}));
return categorizedData;
and works good