Set filter for the link field in web form?

I cant put filter in link field in webform

frappe.web_form.on(‘region’, (field, value) => {
frappe.web_form.set_query(‘city’, function() {
return {
“filters”: {
“region”: frappe.web_form.get_value(‘region’)
}
};
});
})

kindly whats wrong with my code

The code you provided is nearly correct, but there are a few issues that might be causing the problem. Let’s walk through the correct way to apply filters on a link field in a Frappe web form.

frappe.web_form.on(‘region’, (field, value) => {
frappe.web_form.set_query(‘city’, () => {
return {
filters: {
region: value // Use the ‘value’ parameter directly
}
};
});
});

Key Changes:

  1. Use the value parameter:

Inside the event handler for region, the value parameter gives the current value of the region field. You can directly use this instead of calling frappe.web_form.get_value() again.

1 Like