Hide or Restrict Sidebar Options (Assigned to Tags Attachments)

i want to restircit (not hide) side bar options for specific roles
image

Reference: How to hide Toggle sidebar - #2 by NCP

Thanks for the response.
My question is that can we hide for specific users like for managers its visible and cashier its hidden?? same as role permissions.

You can set the condition according to the scenario. script will same, only put your logic.

frappe.user.has_role('Your Role')


like this

yes … !

1 Like

frappe.ui.form.on(‘’, {
onload: function(frm) {
// Roles that should not see the sidebar
let roles_to_hide_sidebar = [‘Role 1’, ‘Role 2’]; // Replace with actual role names

    // Get the current user's roles
    let user_roles = frappe.user_roles;

    // Check if the user has any of the roles in 'roles_to_hide_sidebar'
    let hide_sidebar = roles_to_hide_sidebar.some(role => user_roles.includes(role));

    if (hide_sidebar) {
        // Hide the sidebar
        hide_form_sidebar(frm);
    }
}

});

// Function to hide the form sidebar
function hide_form_sidebar(frm) {
$(frm.page.sidebar).hide();
}

This script is working

its correct but the can u please confirm it will hide in doctype as well like when we create a field and in right side we do all things name label manadatory type kind of things i hope u are getting my points if not i m shairng the screesnhot please look once

IT WILL hide in doctype as well ?

if yes then its a temporary solution i think