Catalog client script is not making variable read only on catalog form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 06:32 AM - edited 12-23-2024 06:34 AM
Catalog client script is not making variable read only on catalog form. The variable name is 'Tier Confirmation'
Here I am checking if catalog task state is closed complete and task name is 'xyz Tier Confirmation'
function onLoad() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('state').toString() == '3' && g_form.getValue('u_task_name') == 'xyz Tier Confirmation') {
g_form.setReadOnly('tier_confirmation', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 06:40 AM
Hi
try
g_form.setReadOnly('variables.tier_confirmation', true);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 06:40 AM
Have you debugged your code to see what value "u_task_name" is returning? You may want to try case-insenstive match by using .toLowerCase()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 09:08 AM
Add alerts to the script before the if statement to see if both conditions are met. Also make sure the 'tier_confirmation' variable name is exactly correct (case and space-sensitive) and is not mandatory, or the read only statement will be ignored.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 09:38 AM - edited 12-23-2024 09:41 AM
Hi @Obito ,
Try below script
function onLoad() {
var taskState = g_form.getValue('state');
var taskName = g_form.getValue('u_task_name');
alert(taskName);// paste the alert tasName in below if condition as this is case and space sensitive
if (taskState == '3' && taskName === 'xyz Tier Confirmation') {
g_form.setReadOnly('tier_confirmation', true);
}
}
—>And also Check if any existing ui policies on the field tier_confirmation which is making read only as false. It will take precedence always.
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand