how to make a field read only based on Logged in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 08:01 AM
I have a Field on my form and I want ti make that field READONLY based on Logged in user.
It should be editable to only 4 users.
I have tried scripting in UI Policy and Onload Client Script, But both are not working.
UI Policy Script:
if(g_user.userName != 'username' || g_user.userName != 'username'){
g_form.setReadOnly('fieldname', true);
Onload SCript:
function onLoad() {
//Type appropriate comment here, and begin script below
alert('the current Logged in user is '+g_user.userName);
var ga = g_user.userName;
if(ga != 'username' || ga != 'username'){
g_form.setReadOnly('field name', true);
}
}
I had imperonated the user and user and checked but it is readonly for him too..
I dont know where i am going Wrong. Can anyone please help.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2019 08:24 PM
Since your condition is not user x OR not user y it is always going to be true and make it read only for everyone, try combining the users with && instead of || which will only be true if the user is not any of the listed users.