Hide Dashboard By Default

When I open a project to manage tasks it always displays the Dashboard in the Down or Visible position.

I do not want that to be the default behavior. I want the default to be hidden unless I select the icon.

I have also noticed when I hide the dashboard and then Save a record the dashboard re-appears.

How can I do this?

Thanks.

Jay

1 Like

put this code in your custom script of that doctype

cur_frm.dashboard.frm.fields[0].df.collapsible=0

7 Likes

can i hide the dashboard from a specific user

Yes, check the user and hide the dashboard in custom script.

1 Like

where i can check the user and write custom script in doctype

@M.Ashraf

You can get userid from session. Based on userid fetch information and hide dashboard.

1 Like

ok how to hide not only collapse ??

cur_frm.dashboard.frm.fields[0].df.hidden=1

2 Likes

Thank you . It works !

i`m trying to make only system admins and accounting are able to see dashboard

so i started with this

frappe.ui.form.on(“Project”, “onload”, function(frm, cdt, cdn) {
if (frappe.user_info(email_id) != “m.ashraf@erpnext.systems”) {
cur_frm.dashboard.frm.fields[0].df.hidden=1;
} });

but it desnt work any user can see the dashboard ??

i also tried this

cur_frm.cscript.custom_validate = function(doc) {
if(frappe.user_roles.indexOf(“Accounts Manager”) == -1) {
cur_frm.dashboard.frm.fields[0].df.hidden=1;
frappe.validated = false;
}
}

but also not working

ok finally made it by

if(!in_list(cur_frm.user_roles,“Dashboard”))
{
cur_frm.dashboard.frm.fields[0].df.hidden=1;
}

and created a new role ‘Dashboard’ then assigned it to all profiles that we don`t want to make them see the dashboard

1 Like

thanks for ur contribution but try this still not working dashboard hide from all user

share your script

i take script from @Mahmoud_Ghoneem

if(!in_list(cur_frm.user_roles,“Dashboard”))
{
cur_frm.dashboard.frm.fields[0].df.hidden=1;
}

1 Like

yes !!

Also to me it hidden the dashboard for the entire system users

Alternatively, you could use CSS to achieve it, we have a custom CSS that has this included:
.form-links.form-dashboard-section {
display:none;
}

Hi ,

Just for the records, I believe the correct script should be something like:

if(!(frappe.user.has_role(['Dashboard'])))
{
cur_frm.dashboard.frm.fields[0].df.hidden=1;
}

Cheers!

3 Likes

Hello,
can you tell me where i have to put this custom script… can you please show

@shanigaram_kartheek You can add it in custom script doctype in your instant:

https://docs.erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts

or in JS folder inside your custom App

1 Like