How to set attachment field mandatory for a specific user role

Hey guys,
I believe this is possible but most probably through a custom script …

I would like to have the event doctype attachment field mandatory only for a specific user role. Anyone has an idea for this ? :slight_smile:

you can add an attachment field as a custom field,then using js you can check logged in user’s role and use toggle_reqd to make it mandatory.

im using like this
if(frappe.user.has_role("role_name")){ frm.toggle_reqd("field_name", true); } else{ frm.toggle_reqd("field_name", false);


Thanks guys for the awesome ideas.

Looking at the solution from @hereabdulla and @Syed_Arab_Al_Taibi - this might work as an alternative.

But, is it possible to use the default attachment field from the left side bar ?

This might not the accurate solution of your question… but you can set if user have the specific role he can see the side Tool Bar so he can attched but to make it mandatory hope any other user will help you with this…

        frappe.ui.form.on("doctype_name", {  
onload: function(me){
refresh: function(me){

else{; //This code will hide the sidebar if user dose not have the 
specific role".timeline").addClass("hide"); // This code will hide the comment box 
below the from if user dose not have the specific role

1 Like

This will be too complicated perhaps. All users must be able to see the side bar to be able to see the attachment …