cancel
Showing results for 
Search instead for 
Did you mean: 
Liliia_DevX
Sisense Team Member
Sisense Team Member

How to hide the "Switch to view mode" button based on a role

This article provides an example JavaScript snippet that could hide the "Switch to view mode" button based on the user's role. 

Screenshot 2024-01-23 at 12.59.43.png


How to use it?

First of all, you need to get the role name you'd like to hide this button for. It can be checked by running GET/roles API v 0.9 in the Sisense Swagger: https://sisense.dev/guides/restApi/v0/?platform=linux&spec=L2023.6#/roles/getAllRoles
 
In our example, we're applying the script to the designer role i.e. 'contributor':

Liliia_DevX_1-1706007100279.png
Secondly,  you need to update the user role in "baseRoleName" in the script and add it to the dashboard via the 'Edit Script' option: 

Liliia_DevX_2-1706007247757.png 

The code snippet:

 

dashboard.on('initialized', () => {

    if (prism.user.baseRoleName === 'contributor') {

        $('button.btn--switch-mode').remove()

    }

})

 

After that, please save the changes and refresh the dashboard page. Hope this helps! 

Disclaimer: Please note, that this blog post contains one possible custom workaround solution for users with similar use cases. We cannot guarantee that the custom code solution described in this post will work in every scenario or with every Sisense software version. As such, we strongly advise users to test solutions in their own environment prior to deploying them to ensure that the solutions proffered function as desired in their environment. For the avoidance of doubt, the content of this blog post is provided to you “as-is” and without warranty of any kind, express, implied or otherwise, including without limitation any warranty of security and or fitness for a particular purpose. The workaround solution described in this post incorporates custom coding which is outside the Sisense product development environment and is therefore not covered by not covered by Sisense warranty and support services.

Version history
Last update:
‎01-23-2024 08:29 AM
Updated by:
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: