Permissions Query in Server Script

Hi Team,

I am trying to write a permissions query in server side script. Here’s my simple code

conditions = 'lead_owner = "{user}"'.format(user=frappe.db.escape(user))

Basically the intent is to show only leads owner by a user to them. I get an error which says

" NotImplementedError: Using format() on a str is not safe."

Which is understandable. But I am unable to work around it. Is there a way to use frappe.format or any other such method for so that this works in a safe way ?

Hey,

why don’t you use the user permission in that case?

You can add user permission following way.