Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
When I use built-in textbox widget, how can I change "ReadOnly" attribute of the textbox widget depends on login user? For example, only users belongs to Administrator group can change value of text box and generic user only can see the value.
Solved! Go to Solution.
Hi Yamini, I don't think that this was what he was asking for.
Hi Satoshi, unfortunately ReadOnly property on TextBox Widget isn't bindable, then you can't set ReadOnly/Not ReadOnly on runtime.
What I would do it's add two widgets the same place, one TextBox and a ValueDisplay, and show/hide them ( visibility property it's bindable ) depending on the current user permissions.
Of course, you have to build a custom service which tells you if the user has ReadOnly or Read/Write access to the given property. This can be done checking the Group's ownership of the user, or as pointed out by Yamini, setting according permissions to the property and checking on this custom service which kind of access has the user on the given property.
To check current user's groups:
var userGroups = Resources["CurrentSessionInfo"].GetCurrentUserGroups();
To check user's permissions to a given property:
var hasReadPermission = me.CheckPermission({ name: "propertyName", type: "PropertyRead" });
var hasWritePermission = me.CheckPermission({ name: "propertyName", type: "PropertyWrite" });
Hi Satoshi, Click on your desired Thingtemplate or thing and select Run Time link in the explorer. Now in (All Properties, Events, and services )-->type the group or user you want to set the permissions. Select the green dot to allow and red dot to deny. You can also set permissions to individual properties in (property,Service or Event Overrides). Let me know if this doesn't solve your problem .
Hi Yamini, I don't think that this was what he was asking for.
Hi Satoshi, unfortunately ReadOnly property on TextBox Widget isn't bindable, then you can't set ReadOnly/Not ReadOnly on runtime.
What I would do it's add two widgets the same place, one TextBox and a ValueDisplay, and show/hide them ( visibility property it's bindable ) depending on the current user permissions.
Of course, you have to build a custom service which tells you if the user has ReadOnly or Read/Write access to the given property. This can be done checking the Group's ownership of the user, or as pointed out by Yamini, setting according permissions to the property and checking on this custom service which kind of access has the user on the given property.
To check current user's groups:
var userGroups = Resources["CurrentSessionInfo"].GetCurrentUserGroups();
To check user's permissions to a given property:
var hasReadPermission = me.CheckPermission({ name: "propertyName", type: "PropertyRead" });
var hasWritePermission = me.CheckPermission({ name: "propertyName", type: "PropertyWrite" });
Hi Carlos,
Thank you for your support. Perhaps, I can realize what I wanted to do in the way you suggested.
Thank you very much.