Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
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?
Solved! Go to Solution.
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.
Buttons have a Visible property which is bindable.
yes but I would like to have it visible but not clickable, is it not possible?
There is a Disabled property as well which is bindable.
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.
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.
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.
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?
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.
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
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