default text in Description field

nameisnani
Mega Sage

Hi Team 

 

when ever user selects ' Request category is ' remove ser access '. below text has to populate in description field .

 

How to achieve this in onchange cilent script .

 

NOTE - Description field where calling from Variable set .

nameisnani_0-1708060642383.png

 

Text :- 

 Exmaple text is required .

 

Please priovde sciript .

 

15 REPLIES 15

@nameisnani 

Could you please accept my solution and mark helpful if it worked for you.

Thanks 

Danish Bhairag2
Tera Sage
Tera Sage

Hi @nameisnani ,

 

Can u check wht is the backend name for Request User Access? Is it the same wht u have entered in the script? request_user_access.

 

Thanks,

 

Lkharat
Tera Expert

 

@nameisnani 

 

you can use the below script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (newValue == 'remove_user_access') { // validate the field name
// Get a reference to the 'Description' field
var descriptionField = g_form.getControl('description');
// Set the desired text in the 'Description' field
descriptionField.value = 'Example text is required.';
}
else {
// Set the 'Description' field value to an empty string
descriptionField.value = '';
}
}

@Maddysunil @Lkharat @Danish Bhairag2 @Aniket Bhanse 

 

nameisnani_0-1708064298992.png

nameisnani_1-1708064386747.png

 

 

where I missed , can anyone please help me here .

Update your code like this:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   
    if (newValue == 'remove_user_access') { // validate the field name
        // Get a reference to the 'Description' field
        //var descriptionField = g_form.getControl('description');
        // Set the desired text in the 'Description' field
        g_form.setValue('description','Your text here');
    }
else {
 g_form.setValue('description','');
}
}