How to make fields readonly using client script based on choice value as No
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-09-2023 02:14 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-09-2023 06:50 AM
hi team,
i am facing issue with the client script below:
Based on choice field u_additional_peer_review_completed value as yes i need to make the u_additional_peer_review_date' as read only.
u_additional_peer_review_completed field have two choice field values yes ,no.
In the if condition if i am giving as yes u_additional_peer_review_date this field is not coming as readonly.
Only for no and None u_additional_peer_review_date is displaying as readonly.
please let me know should i need to change anything in my code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var additional_peer_item= g_form.getValue('u_additional_peer_review_completed');
if(additional_peer_item =='yes')
g_form.setReadonly('u_additional_peer_review_date',true);
else
g_form.setReadonly('u_additional_peer_review_date',false);
//Type appropriate comment here, and begin script below
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-09-2023 07:11 PM
Hi I dont see flower bracket after if and else statement, do like below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var additional_peer_item= g_form.getValue('u_additional_peer_review_completed');
if(additional_peer_item =='yes')
{
g_form.setReadonly('u_additional_peer_review_date',true);
}
else
{
g_form.setReadonly('u_additional_peer_review_date',false);
}
//Type appropriate comment here, and begin script below
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-10-2023 12:47 AM
Hi Kavitha,
It means your if part is working you need to check your choice values and configured it correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-10-2023 01:02 AM
Hi Kavitha,
I would suggest you to use UI policy instead of Client Script for this requirement as it is easy to use and debug later.
But if anyways you want to use this client script then please make sure you have selected a "Variable Name" because I see your client script is onChange. So you need to define that on what field change you want this client script to run.
If my answer helps then please mark it Helpful or Correct!
Thanks,
Utpal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-09-2023 09:09 PM
You can achieve this by ui policy also