How to filter Link field in query report based on other field

Hi All,

I am new to ERP Next. i am preparing a script report with filters. I have two link fields in the filters, one is to load states another one is for districts. Now i want to display the districts list in the filter based on the selected state. can anyone suggest how can i achieve that?
For Eg: If i select Kerala in state filter then when i click on the district it should display only districts from kerala not from other states.

Thank you

Hello @ERPNext_Usr

I’ve written a tutorial on doing just this but for a Script Report : [Tutorial] Script Report / Chart - #14 by EugeneP

Thank you for your reply and tutorial which is very good.
I tried the filter part but unfortunately it wasn’t working for me please suggest

on_change: function(query_report){
query_report.set_filter_value(‘district_code_data’, []);
console.log(“State code selected …”)
(“District Code”),
get_data: function(txt) {
if (frappe.query_report.get_filter_value(‘state_code’)) {
var name = frappe.query_report.get_filter_value(“state_code”);
return frappe.db.get_list(“Employee”, {fields: [‘district_code’], filters: {“state_code”: name}, distinct: 1});
//return frappe.db.get_link_options(“Activity Log”, txt, {“user”:name});
else {
console.log(“Else condition…”)
return [];
on_change: function(query_report) {
console.log(“On change district code…”)