Restrict access to a certain field value

Hello,

I have created a custom select field on the Lead screen.
I would like to restrict the access of a user based on one value from the picklist.
eg If in the select field there are two categories A and B, I want the user to have access to only A and not see any record created with B.

I have checked on the user permissions screen, I can only restrict by Lead, and not a specfic field on the Lead screen.

Please advise

Kind Regards,

  • Use Server Script
  • Script Type = Permission Query
  • Reference Doctype = Applicable Doctype (Here Picklist)

Script:

if frappe.session.user == "a@gmail.com":
    conditions = "`field_name` = 'A'" 

Basically this will extend the database query condition string to get the desired data.

1 Like