I have three filter fields. My requirement is that if the first field is set, then the other two fields should be optional. However, if the first field is not set, then the other two fields should be required.
Is this code working for you? I’m encountering an issue where the on_change event is not triggering. I’m currently using Frappe version 15.23.0. Here’s my code snippet:
@Abdeali Thanks for your reply, I’m not sure what the previous problem was, but now the code seems to be working in the on_change event. However, the issue is that even after updating to 0, it still shows an error message indicating that the filter is missing.
I’ve tried two methods, but unfortunately, neither of them is working. Here’s my code snippet
you can try add the logic on the query / script report
Query / Script :
columns = [
your columns here
]
lett = []
filter_1 = filters.get("filter_1")
filter_2 = filters.get("filter_2")
filter_3 = filters.get("filter_3")
sql_2 = """
your query here
"""
sql_2 = """
your query here
"""
sql_3 = """
your query here
"""
###This example for your logic condition for filter
if filter_3 is None and filter_2 is None:
lett = frappe.db.sql(sql_1, (filter_1), as_dict=True)
elif filter_1 is None:
lett = frappe.db.sql(sql_2, (filter_2), as_dict=True)
else:
lett = frappe.db.sql(sql_3, (filter_3), as_dict=True)
data = columns, lett
@Gembira_IT_Tech Thanks for your reply. My query is about dynamically changing mandatory fields. For instance, if the first field is filled, then the other two fields should not be mandatory, but if it’s empty, then the other two fields should be mandatory. I need to implement this logic in JavaScript, as handling the logic in Python will be easy for me
@Abdeali, thanks for your reply and time. I’m currently running the above exact code, and it automatically sends requests to the backend in a loop. I’ll provide a screenshot for your reference.