Onchange client script to make fields readonly after entry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 05:25 AM
Hello I have a requirement where on service portal record producer form , when the user enter a data in a field and select the next field it should be readonly , is this possible ? if yes can some one help me with the code
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 11:05 AM
This is an on change script I have on a variable called first_name. Once the filed has something in it it becomes read only. Note that you have to make sure the UI Type on your client script is All.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue != ''){
g_form.setReadOnly('first_name', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2018 06:30 AM
Thanks for the reply but i have 17 variables , is there any way we can do this to all variables in one client script instead of creating 17 on change client scripts, for each variable ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2018 11:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 03:41 PM
I'm not sure this is possible as a client script would need to be an on change and you can only run that against 1 variable. I'm wondering why you have this requirement. What if a user enters something into variable A and then goes the variable B. If they realize what they put into variable A is incorrect they have no way to change it. This is usually not best practice.