nikzz
November 14, 2018, 6:46am
1
I have a link field whose value i want is to change on another select field.
Doctype A → Doctype 1
Doctype B → Doctype 2
I am having a field option and category in Doctype B which is link field for Doctype A
frm.set_query("option", "doctype B", function() {
return {
filters: {
"category": cur_frm.doc.category
}
}
});
cur_frm.refresh_field('option');
But its not working.
What I want is on changing field value of category in Doc B, only the list of those (from Doc A) appears in link field having category same as selected in Doc B. I had already created caetgory field in Doc A also
Check this, you’ll get an idea.
// License: GNU General Public License v3. See license.txt
{% include 'erpnext/selling/sales_common.js' %};
cur_frm.add_fetch('customer', 'tax_id', 'tax_id');
frappe.provide("erpnext.stock");
frappe.provide("erpnext.stock.delivery_note");
frappe.ui.form.on("Delivery Note", {
setup: function(frm) {
frm.custom_make_buttons = {
'Packing Slip': 'Packing Slip',
'Installation Note': 'Installation Note',
'Sales Invoice': 'Invoice',
'Stock Entry': 'Return',
},
frm.set_indicator_formatter('item_code',
function(doc) {
return (doc.docstatus==1 || doc.qty<=doc.actual_qty) ? "green" : "orange"
})
nikzz
November 14, 2018, 7:15am
3
thanks, solved using this:
frappe.ui.form.on("Draft", { "category": function(frm) {
frm.fields_dict['option'].get_query = function(doc) {
return {
filters: { "category": cur_frm.doc.category }
}
}
cur_frm.refresh_field('option');
}
});
BTW I don’t guess refresh field is helping me out anyhow . Correct me if I’m wrong
1 Like
You may need to put it in setup event which fired only one time when form created.
Edit:
Yes, refresh field is not needed here.