hclleapforum

Open full view…

Hiding the buttons in a form based on user role

pgmer
Mon, 04 May 2020 13:36:59 GMT

Is there a way to hide/show the buttons in a stage based on the user role defined in the access tab? There are few buttons in the update stage which I want to hide based for normal users and visible only to Administrators. How can it be achieved?

christopher_dawes
Thu, 14 May 2020 15:36:08 GMT

There is no default mechanism for this. One missing piece is that there is no function to tell you what role a user is part of. I posted an extension that you could download and install that adds a few functions to help with this (https://hclwiki.atlassian.net/wiki/spaces/HL/pages/461223/Custom+Transport+-+Leap+Roles). With this extension you can make a service call to find out if a user is in a specific role and then hide/show the buttons.

pgmer
Fri, 26 Jun 2020 06:34:48 GMT

Ok.. thanks Christopher. I'll try this out. Two questions regarding the same - (1)How do I add the check for the stage button to show or hide the button based on the role. I don't see any options in the Advanced tab also. (2) How do I retrieve the logged in User's mail id programatically?

christopher_dawes
Fri, 26 Jun 2020 19:18:45 GMT

In Leap you can use app.getCurrentUser() to retrieve the current user's login id. If the login id is not their email then you will have to make an ldap request to get the email. We have a feature request for a new function that will return all the information about a user (display name, login id and email) that we keep in our user table. Hiding or showing a button based on a specific user or role is not something that is in Leap today. You can accomplish it if you have deployed my custom Transport called Role management (on the wiki and free to download). If you want to only show the button for a specific user , based on user id, then you can do that using javaScript.