Has a better method to do this? I tried parse both fields on get_field
arg but not worked…
local_manutencao: function (frm) {
frm.fields_dict.purposes.grid.get_field('field_1').get_query = function () {
return {
filters: {
"department": ["in", ["Diretoria", "Assistência Técnica"]] }
}
}
frm.fields_dict.purposes.grid.get_field('field_like_1').get_query = function () {
return {
filters: {
"department": ["in", ["Diretoria", "Assistência Técnica"]]
}
}
}
}
@Leonardo_Augusto
Code seems to be fine, can you check local_manutencao function has called from the setup or refresh function?
The code is working fine, I wanna help to refactor that, I’m using a lot of code to do the same thing in two fields.
Maybe has another method instead get_field which get more than 1 field, or another way to parse more than one argument to get_field
method.
No there is no option to pass more than one argument, maybe you can commonify you code as below
local_manutencao: function (frm) {
['field_1', 'field_like_1'].forEach(fieldname => {
frm.fields_dict.purposes.grid.get_field(fieldname).get_query = function () {
return {
filters: {
"department": ["in", ["Diretoria", "Assistência Técnica"]] }
}
}
})
}
1 Like
Better than mine, thank you 
Not worked, I’ll research about js syntax while that…
If you notice some frappe method that supports more than one arg let me know. I’m best pratices entusiast and newbie 