How to make some variables editable while entering data in single line text variable?

Ashwini Jadhao
Giga Guru

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

 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi SnowDev,

To make field "Provide Code" have max length of 17 characters, set Variable attribute to "max_length=17".

find_real_file.png

 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.

find_real_file.png

case 2: Provide code is 17 characters.

find_real_file.png

 

View solution in original post

7 REPLIES 7

Sai Kumar B
Mega Sage
Mega Sage

@snowDEV 

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

}

 

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi SnowDev,

To make field "Provide Code" have max length of 17 characters, set Variable attribute to "max_length=17".

find_real_file.png

 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.

find_real_file.png

case 2: Provide code is 17 characters.

find_real_file.png

 

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.

Ashwini Jadhao
Giga Guru

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