mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-12 17:23:38 +00:00
Updated Community Developed Custom Scripts (markdown)
@@ -85,6 +85,29 @@ frappe.ui.form.on("Dropbox Backup", "refresh", function(frm){
|
||||
```
|
||||
|
||||
***
|
||||
### Calculating Values in Child Tables
|
||||
|
||||
to calculate the values of child tables, you can use the following functions:
|
||||
```
|
||||
frappe.ui.form.on("[CHILD TABLE DOCTYPE]", {
|
||||
[CHILDTABLEMULTIPLE1]: function(frm, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
var total = 0;
|
||||
frappe.model.set_value(d.doctype, d.name, "[CHILDTABLEPRODUCT]", d.[CHILDTABLEMULTIPLE1] * d.[CHILDTABLEMULTIPLE2]);
|
||||
frm.doc.[CHILDTABLEFIELDINPARENT].forEach(function(d) { total += d.[CHILDTABLEPRODUCT]; });
|
||||
frm.set_value('[PARENTDOCTYPETOTALFIELD]', total);
|
||||
}
|
||||
});
|
||||
frappe.ui.form.on("[CHILD TABLE DOCTYPE]", {
|
||||
[CHILDTABLEMULTIPLE2]: function(frm, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
var total = 0;
|
||||
frappe.model.set_value(d.doctype, d.name, "[CHILDTABLEPRODUCT]", d.[CHILDTABLEMULTIPLE1] * d.[CHILDTABLEMULTIPLE2]);
|
||||
frm.doc.[CHILDTABLEFIELDINPARENT].forEach(function(d) { total += d.[CHILDTABLEPRODUCT]; });
|
||||
frm.set_value('[PARENTDOCTYPETOTALFIELD]', total);
|
||||
}
|
||||
});
|
||||
```
|
||||
### Fetch child table
|
||||
|
||||
The following fetches all entries in a child table from another document.
|
||||
|
||||
Reference in New Issue
Block a user