I have 2 tables (libraries), "orders" and "order details".
"orders" has the "order number" field.
"order details" has the fields "order number" (one-to-many relationship with "orders"), "quantity" and "price".
How do I get the general total (sum(quantity * price)) from "order details" in the table (library) "orders"? It's possible? The example specified in the wiki does not work for me.
Example: Order containing items
The library Orders contains orders and the library Items contains items. Orders contains a link Items to library Items. Items contains the fields Quantity and Price. To calculate the cost of the order, the JavaScript field Cost can be computed as follows:
var items = field('Items'); // CHANGE Items to your link field name
var cost = 0;
for (var i in items)
cost += items[i].field('Quantity') * items[i].field('Price');
cost; // The result is the COMPUTED COST
Order (lib)
Number order (field, txt)
Total order (Javascript, sum(Quantity)*(Price) in Detail order lib)
Detail order (lib)
Number order (field for link 1 to many)
Quantity (field, real)
Price (field, real)
how do I calculate the Total order (field in Order lib)?
In the Detail order library I calculated the field "total" (quantity * price), then I did as the guide says
Example: Sum of linked amount
var amountField = "total";
var linkedEntries = field("detail order");
var numLE = linkedEntries.length;
for (var lex = 0, result = 0; lex < numLE; lex++)
result += linkedEntries[lex].field(amountField);
result;
Not found. This is because the variable "numLE". This returns me a strange number that varies with the name of the indicated linked library in linkedEntries (23 if "detail order", 22 if "detail orde", 21 if "detail ord")...
Somebody help me, please? I refer to the paid version for Android.
--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodatabase+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I was wondering if you can set "readonly" the fields used for calculations. Editable only with calculations, not manually.
Memento is very useful
Another thing:
I've also set up calculations for deleting items, not just for adding and editing data. It works well if I delete a record after I see it by clicking on it. It does not work, however, if I delete the records by selecting them from the main window of the library because the fields specified in the triggers are not found. Can this problem be solved in any way?