ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Override the Link field based on Select Field


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

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.


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 }

BTW I don’t guess refresh field is helping me out anyhow :thinking: . Correct me if I’m wrong :slight_smile:


You may need to put it in setup event which fired only one time when form created.

Yes, refresh field is not needed here.


thank you