- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-23-2022 11:05 PM
Hi Community,
Is there a way to make variable read only when I enter a data in single line text variable.
For example,
Single line text variable: Provide Code : Entered string length is 17 character.
when I add 17 character value in Provide code then Description variable should be editable.Right now description is a Readonly type
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-23-2022 11:29 PM
Hi SnowDev,
To make field "Provide Code" have max length of 17 characters, set Variable attribute to "max_length=17".
To make Description field editable when Provide Code is 17 characters, create a onChange client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setReadOnly('description', true); // set to readonly as default
return;
}
if (newValue.length == 17) {
g_form.setReadOnly('description', false); // make description field editable only when provide_code is 17 characters
} else {
g_form.setReadOnly('description', true);
}
}
Execution result:
case 1: Provide code is less than 17 characters.
case 2: Provide code is 17 characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-23-2022 11:18 PM
1.) You can write onChange() Catalog client script on "provide Code" variable
2.) Write the below script inside client script onChange() function
SCRIPT
if(newValue) { //newValue is the provide code new value
g_form.setReadOnly('description_variable_name', false); //Make description editable
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-23-2022 11:29 PM
Hi SnowDev,
To make field "Provide Code" have max length of 17 characters, set Variable attribute to "max_length=17".
To make Description field editable when Provide Code is 17 characters, create a onChange client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setReadOnly('description', true); // set to readonly as default
return;
}
if (newValue.length == 17) {
g_form.setReadOnly('description', false); // make description field editable only when provide_code is 17 characters
} else {
g_form.setReadOnly('description', true);
}
}
Execution result:
case 1: Provide code is less than 17 characters.
case 2: Provide code is 17 characters.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-23-2022 11:30 PM
BTW, there isn't a OOTB way to make description field editable as user is entering values into Provide Code field. User needs to move on to the next field to change the read-only status.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-23-2022 11:39 PM
Thank you all for your responses.
Variable length I can not set with variable attribute because input may vary from 11 to 22 characters.
and also can not right onchange script because I don't want to make Description editable onchange on Provide code.
I want to make it editable when I enter data in Provide code