cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Disable button if user can't use it

SOLVED
Highlighted

Disable button if user can't use it

Hello! 
So I have a button that I would like to disable when a specific user doesn't have runtime permission to the service linked to that button. How can I do it? 

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Disable button if user can't use it

The Button only receives true and false to enable and disable it's function, so you need to define the logic which user can use them.

 

If you can use Validator language to realize the logic, you can use the validator command, if not, you can create a js service and add it to your data source.

 

It may look like :  return Resources["CurrentSessionInfo"].GetCurrentUser() in ['Abby','Bob','Chandler','Ella'];  and it gives out a true or false result.

View solution in original post

10 REPLIES 10
Highlighted

Re: Disable button if user can't use it

Buttons have a Visible property which is bindable. 

Highlighted

Re: Disable button if user can't use it

yes but I would like to have it visible but not clickable, is it not possible?  

Highlighted

Re: Disable button if user can't use it

There is a Disabled property as well which is bindable. 

Highlighted

Re: Disable button if user can't use it

Hello again, yes it is bondable but can you teach me how? I have a service that the result tells me if a user isAdmin  (true or false) and I would like to disable this button if false.  

Highlighted

Re: Disable button if user can't use it

If a true value is bound to Disabled property then the button is disabled. So, in your case you may have to pass true from the service if the user is not an Admin, to disable the button(instead of false). 

 

From under Returned Data -> All Data of your service drag your result variable to the disabled property to create the binding. 

 

 

Highlighted

Re: Disable button if user can't use it

The service you need may be complex, and you need to customize the script

 

Approach 1:

Add a property or assign values to Existing properties of the User entity, check the value of the property to define whether to return true or false to the mashup

 

Approach 2:

Use Group to decide whether the User can see/enable the button.  If the User is in certain group, return true.

Use Groups["group name"].GetGroupMembers(); to retrieve the User list, and check if getCurrentUser() is in this infotable result.

Highlighted

Re: Disable button if user can't use it

Hello! Thank you for the suggestions. I've added an User extension and now I'm trying to use a Validator (function) on the mashup to disable the button. However it only returns true or false and I'll have 7 types of users, any advice on how to optimize which buttons to disable according to the User? 

Highlighted

Re: Disable button if user can't use it

The Button only receives true and false to enable and disable it's function, so you need to define the logic which user can use them.

 

If you can use Validator language to realize the logic, you can use the validator command, if not, you can create a js service and add it to your data source.

 

It may look like :  return Resources["CurrentSessionInfo"].GetCurrentUser() in ['Abby','Bob','Chandler','Ella'];  and it gives out a true or false result.

View solution in original post

Highlighted

Re: Disable button if user can't use it

Use Group to decide whether the User can see/enable the button.  If the User is in certain group, return true.

Use Groups["group name"].GetGroupMembers(); to retrieve the User list, and check if getCurrentUser() is in this infotable result.

 

You can use a swtich condition to check through 7 type of users 

Highlighted

Re: Disable button if user can't use it

Hi @JulianaGuerra.

 

If you feel your question has been answered, please mark the appropriate reply as the Accepted Solution, for the benefit of others with the same question.

 

Regards.

 

--Sharon

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!