ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Filter in Frappe Call as Optional


#1

My case is when user A logs in the filter condition in frappe call works but if user B logs in, the filter kindof hides like it doesn’t exist. In short, i am trying to use filter as a terninary operator. Any suggestion for doing so or I need to write 2 frappe-calls for each user A & B.

Thank you


#2

tried this

var zxc = (user_role=="HR" ? "filters: { 'role':"+user+"}":"filters: {}")
console.log(zxc)

  frappe.call({
    method:"frappe.client.get_list",
    args: {
      doctype:"RSet",
      fields: ['act'],
      zxc,
    },
    async:false,
    callback:function(r){
      console.log(r.message
    }
});

But it is giving all the values. Any help ??


#3

solved. was doing silly mistake

var zxc = (user_role=="HR" ? '{"role":"'+user+'"}':'{}')

and in frappe call intead of zxc, i used

filters: zxc,

#4