Hi all, i am working on to display the button for particular user only i.e ‘QA Manager’ i have given eval:frappe.user.has_role(‘QA Manager’) && doc.pending_qa_approval == 1 for the stp field which datatype has ‘button’…but the ‘stp button’ is not visible for the ‘QA Manager’ is anything i missed out in eval?
Not sure whether it will work or not but
gives current logged in user’s role in console . You can try with that, just change the array where your desired role is mentioned.
Hope this will work
sorry, @nikzz i can’t get your point can u explain it. How can i give current logged in user role in console? I want the ‘stp’ button automatically has to be display when i opened the ‘QT’ record
(login as ‘QA Manager’ )
This will give all roles in an array in console, in array form. Just use the index of the role you want as, let say QA Manager lies at 41’th index . So use,
I’m not sure how well this code works in eval or rather I’d say I have no documented examples if such a thing works but why not put this in Custom JS ? That would be straightforward.
doc.pending_qa_approval == 1
This can stay in
Restrict this field’s Perm level say to 1. Then in Role Permissions Manager, allow QA Manager to edit fields with permlevel 1
hi @root13F i tried this role permission but button is not visible in ‘QA Manager’ even if there is no display depends on condition also button is not visible in ‘QA Manager’ except that ‘stp’ button field all other fields are displayed in ‘QA manager’…how can this done in custom js?
In refresh event try this line of code :
cur_frm.toggle_display('stp', frappe.user.has_role(""QA Manager))
Later on check from both users - Non QA manager and QA Manager
Edit : Also hide this field via the docfield properties.
hi @root13F i tried but not worked so i made the button has custom button and wrote user role validation in js.
did you find a workaround?
happening on my side as well