Filter on link data for a link data field

frappe.ui.form.on(“Pre Enrollment”, “onload”, function(frm) {
var school_year = cur_frm.doc.school_year
console.log(school_year,‘ss’)

if (!frm.doc.strand) {
    console.log(school_year)
    frm.set_query("strand", function(school_year) {
        return {
            
            "filters": {
                "school_year": school_year,
            }
        };
    });
}

});

Hi @John_Dagpin,

Please apply it.

frappe.ui.form.on("Pre Enrollment", "onload", function(frm) {
  var school_year = cur_frm.doc.school_year;
  console.log(school_year, 'ss');

  if (!frm.doc.strand) {
    console.log(school_year);
    frm.set_query("strand", function() {
      return {
        filters: {
          school_year: school_year
        }
      };
    });
  }
});

Then reload (Ctrl + Shift + R) and check it.

Reference: Overriding Link Query By Custom Script

Thank You!