Hi,
With reference of the following links,
Hi @KanchanChauhan . Finally got it working with the below code ,
frappe.ui.form.on("heatiss", "item_code", function(frm, cdt, cdn){
frappe.after_ajax(function() {
var d = locals[cdt][cdn];
frappe.call({
"method": "frappe.client.get_value",
args: {
doctype: "Customer TDC",
fieldname: "data_172",
filters: {
part_number:["=", d.item_code]
}
},
callback: function (data) {
console.log(data);
frappe.model.s…
@rmehta triggering item_code change and the result is the same… msgprint(d.warehouse) did show the expected warehouse value but it go back to previous default value… What may cause this?
frappe.ui.form.on("Sales Invoice Item", "item_code", function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Customer",
fieldname: "warehouse",
…
I am still unable to show “warehouse” in Sales Invoice Items. Custom FIeld “warehouse” created in Customer DocType.
Basically, I want the Warehouse in SI Items to be updated based on the Customer selection.
My code:
frappe.ui.form.on("Sales Invoice Item", "item_code", function(frm, cdt, cdn) {
frappe.after_ajax(function() {
var d = locals[cdt][cdn];
frappe.call({
method: "frappe.client.get_value",
args: {
doctype: "Customer",
fieldname: "warehouse",
filters: { name: frm.doc.customer },
},
callback: function(r) {
if (r.message.warehouse){
frappe.model.set_value(cdt, cdn, "warehouse", r.message.warehouse);
//msgprint(d.warehouse);
}
else {
frappe.throw("Warehouse not found for Customer : " + frm.doc.customer);
}
}
});
});
});
jof2jc
December 10, 2016, 2:15am
2
try to use trigger on item_name
change instead of item_code
Hi!
Nope. Not working either.
gvrvnk
December 10, 2016, 7:44am
4
Try this:
frappe.ui.form.on("Sales Invoice Item", "item_code", function(frm, cdt, cdn) {
frappe.model.get_value("Customer", cur_frm.doc.customer, "warehouse", function(r) {
var d = locals[cdt][cdn];
d["warehouse"] = r.warehouse;
});
});
Hi
Thanks for the reply. Still unable to get it to work.
From what I understand after looking through the forums, we need to put the custom script in the master instead of the child table. It won’t trigger if we put this inside the child table.
Hi @mulyadi-agtechsg ! it should be like this
cur_frm.cscript.{field_under_child_table} = function (doc, cdt, cdn) {
var d = locals[cdt][cdn];
/do something here /
}
ex.
If I have child table A and has field sample_field then it will be like this
cur_frm.cscript.sample_field = function (doc, cdt, cdn) {
var d = locals[cdt][cdn];
/do something here /
}
Take note: This script should be under the Parent Doctype, in your case it should be in Sales Invoice
1 Like
Hi @johnskywalker
OK, at least it triggered when using item_code field.
However, it does not get all the details into the item details.
Findings so far.
Using item_code to trigger, it triggers but all item details will not be retrieved
Using item_name to trigger, does not trigger
jof2jc
December 15, 2016, 8:30am
8
Try to trigger when user change qty
Paul
July 23, 2019, 12:05pm
9
please help me . how can i use this code ?