nikzz
January 21, 2019, 12:52pm
1
I am trying to put multiple filters in my code where the use case is
→ First Filter should always be checked
→ There should be an OR statement for filter 2 as (field a: condition OR field b: condition OR field c: condition)
This is my code with single filter
frappe.ui.form.on("Doc", "category", function(frm) {
cur_frm.set_query("scr", function() {
return {
"filters": {
"category": cur_frm.doc.category,
}
};
});
});
I tried filters as
"filters":[ ['category','=',cur_frm.doc.category ],[['field a','=',condition] || 'field b', '=',condition ] ] ]
But I am getting error
ANY HELP
2 Likes
nikzz
January 21, 2019, 1:06pm
2
This is the error what I am getting
ValidationError: Filter must have 4 values (doctype, fieldname, operator, value): [[u'Scr', u'segment', u'Like', u'ABC']]
Doctype name is missing in your filters!
check this link:
https://frappe.io/docs/user/en/guides/app-development/overriding-link-query-by-custom-script
I suggest using Custom Method because of the flexibility of database query
nikzz
January 23, 2019, 8:59am
5
Followed this way but still getting error
frappe.ui.form.on("Bank Reconciliation", "onload", function(frm){
cur_frm.set_query("bank_account", function(){
return {
"filters": [
["Bank Account": "account_type", "=", "Bank"],
["Bank Account": "group_or_ledger", "!=", "Group"]
]
}
});
});
Its giving error in custom script , the “Bank Account”: this if removed makes my code working but not able to apply filter as per my condition
snv
January 23, 2019, 9:12am
6
You syntax is invalid:
nikzz:
[“Bank Account”: “account_type”, “=”, “Bank”], [“Bank Account”: “group_or_ledger”, “!=”, “Group”]
Replace with:
["Bank Account", "account_type", "=", "Bank"],
["Bank Account", "group_or_ledger", "!=", "Group"]
nikzz
January 23, 2019, 9:13am
7
Already tried, I am getting this
ValidationError: Filter must have 4 values (doctype, fieldname, operator, value): [[u'Scr', u'segment', u'=', u'ABC']]
nikzz
March 19, 2019, 11:14am
8
Solved.
[Doctype name , field name, operator, value]
1 Like
Did this solution work?
[“Bank Account”, “account_type”, “=”, “Bank”],
1 Like
"filters":[ ['category','=',cur_frm.doc.category ],[['field a','=',condition] || 'field b', '=',condition ] ] ]
OR ( || ) is not supported, it throws
SyntaxError: invalid syntax
how does OR conditions work in frappe filters?
I dont see any documentation on it either