How to make fields readonly using client script based on choice value as No

kavitha N
Tera Contributor

I want to make  calender Date time field readonly based on a condition where a field with choices yes and No is selected as yes using client script

9 REPLIES 9

Sohail Khilji
Kilo Patron
Kilo Patron

@kavitha N ,

 

For this you can create a UI policy with the condition as 

When Field value is 'no'.

 

and from the related list UI policy action you can create a new action to make date_field read only.

 

I Hope this helps !

 


ā˜‘ļø Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Mohith Devatte
Tera Sage
Tera Sage

Hello @kavitha N ,

you can configure an on change client script on the yes or no field and can write a script as below

 

 

if(newValue=="Yes"||newValue=="yes")
{
g_form.setReadOnly('your_date_time_field_backend_name' , true);
}

 

 

 

OR 

 

Create a UI policy with condition as yes or no field is Yes

and in the UI policy actions create a new action where your date time field can be set to read only

 

Hope this helps 

 

Mark my answer correct if this helps you 

Thanks

 

Harish KM
Kilo Patron
Kilo Patron

Hi you can create a OnChange client script on yes/no variable

Script:

var CheckYes= g_form.getValue('variablename');
    alert(CheckYes);
    if(CheckYes== 'yes')
        {
            g_form.setReadOnly('Variablename',true);
        }
Regards
Harish

AndersBGS
Tera Patron
Tera Patron

Hi @kavitha N ,

 

Why use client scripts when an UI policy without scripting can solve your query?

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/