From 9aca025be230e764c9dfa7c24edca93a45a6b133 Mon Sep 17 00:00:00 2001 From: Jignesh Greycube Date: Wed, 30 May 2018 15:08:55 +0530 Subject: [PATCH] Documentation to Fetch value in Child Table for a field (#14282) * Fetch value in Child Table for a field Sample Script to fetch value in child table * Update fetch value in child table field --- .../fetch value in child table field | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/fetch value in child table field diff --git a/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/fetch value in child table field b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/fetch value in child table field new file mode 100644 index 0000000000..8caf8f57c4 --- /dev/null +++ b/erpnext/docs/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/fetch value in child table field @@ -0,0 +1,17 @@ +## Example to fetch value in a child table field from master doctype + + +### Sample Script to fetch expiry_date field from Batch doctype to Sales Invoice Item table + +Step 1: Create Custom Script for _**Sales Invoice**_ (parent) doctype + +Step 2: Script as below & Save + +``` +frappe.ui.form.on("Sales Invoice Item", "batch_no", function(frm, cdt, cdn) { + var d = locals[cdt][cdn]; + frappe.db.get_value("Batch", {"name": d.batch_no}, "expiry_date", function(value) { + d.expiry_date = value.expiry_date; + }); +}); +```