[SOLVED] Dynamic filters in Script Report

Hi

var subjects = '';
//subjects = ['hello','world']
frappe.call({
    method: "my_app.school_combined_grades_report.getParentSubjects",
    callback: function (r) {
        subjects = r.message["result"]
        console.log(subjects)
    }
});

frappe.query_reports["SOME REPORT"] = {
	"filters": [
        {
			"fieldname":"parent_subject",
			"label": __("Subject"),
			"fieldtype": "Select",
			"options": subjects,
		}
	]
}

r.message[“result”] is not empty, but in my filter options, subjects is empty.

Solved. Finally got it working

just need to

 {
			"fieldname":"parent_subject",
			"label": __("Subject"),
			"fieldtype": "Link",
			"options": "Subject",
            "get_query": function() {
				//var x = frappe.query_report_filters_by_name.subject_kind.get_value();
                var x = 'Parent';
                console.log(x);
				return {
					"doctype": "Subject",
					"filters": {
						"kind": x,
					}
				}
			}
		}
1 Like