- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago - last edited 4 hours ago
I am trying to make all variables readOnly in the variable editor. To achieve this, I used the following approach:
Used the method: g_form.setVariablesReadOnly(true); in an onLoad client script.
All fields became read-only but not the Glide List (List Collector) fields, especially for those where Catalog UI policies applied to these fields.
I attempted the following additional steps:
Used g_form.setMandatory(false) and g_form.setReadOnly(true) explicitly on the Glide List fields. Despite these efforts, the Glide List fields remain editable.
Expected Behavior:
All variables, including Glide List fields, should be read-only when the assignment group is 'xxxxx'.
Could you please advise on the correct approach or provide guidance on how to make Glide List fields read-only along with other variables?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @RGC9,
Catalog UI Policies execute after onLoad Client Scripts. Even if your script sets the field to Read-Only, a UI Policy running 100ms later can refresh the field and revert the Read-Only state, especially if "Reverse if False" is enabled on that policy.
Here're the 3 options you can try and lemme know which works for you:
Option 1:
Wrap your code in a slight delay to ensure it runs after the UI Policies have finished loading.
function onLoad() {
var group = g_form.getValue('assignment_group');
if (group == 'YOUR_GROUP_SYS_ID') {
setTimeout(function() {
g_form.setVariablesReadOnly(true);
}, 1000); // 1 second delay to let UI Policies finish
}
}Option 2:
Find the Catalog UI Policy affecting that List Collector.
If the UI Policy is only meant for the Catalog Item view (and not the RITM/Task view), uncheck "Applies on Requested Items" and "Applies on Catalog Tasks".
If it must run on the Task, ensure there isn't a "Read Only: Leave Alone" or "Read Only: False" action conflicting with your script.
Option 3:
For List Collectors specifically, sometimes setDisabled works when setReadOnly struggles against the DOM.
g_form.setDisabled('variables.your_variable_name', true);If you find my response helpful, mark it as helpful and accepted solution.
Regards,
Maham Tahir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
The onLoad Client Script that you used is the best approach. It works for all types of variables, including both formats of List Collectors. What you need to do in your specific case is remove the other UI Policies or Client Scripts that are colliding with this one - to make it read only false and/or mandatory true. Your onLoad script is probably on the RITM record and/or Catalog Task record, and/or only when active is false, so make the other policies/scripts not apply under the same conditions. If you're still stuck, share which record(s) you're attempting this on (RITM, Catalog Task), under what conditions if any, and the conflicting policies/scripts and what their intention is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @RGC9,
Catalog UI Policies execute after onLoad Client Scripts. Even if your script sets the field to Read-Only, a UI Policy running 100ms later can refresh the field and revert the Read-Only state, especially if "Reverse if False" is enabled on that policy.
Here're the 3 options you can try and lemme know which works for you:
Option 1:
Wrap your code in a slight delay to ensure it runs after the UI Policies have finished loading.
function onLoad() {
var group = g_form.getValue('assignment_group');
if (group == 'YOUR_GROUP_SYS_ID') {
setTimeout(function() {
g_form.setVariablesReadOnly(true);
}, 1000); // 1 second delay to let UI Policies finish
}
}Option 2:
Find the Catalog UI Policy affecting that List Collector.
If the UI Policy is only meant for the Catalog Item view (and not the RITM/Task view), uncheck "Applies on Requested Items" and "Applies on Catalog Tasks".
If it must run on the Task, ensure there isn't a "Read Only: Leave Alone" or "Read Only: False" action conflicting with your script.
Option 3:
For List Collectors specifically, sometimes setDisabled works when setReadOnly struggles against the DOM.
g_form.setDisabled('variables.your_variable_name', true);If you find my response helpful, mark it as helpful and accepted solution.
Regards,
Maham Tahir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @Maham Tahir, option 1 perfectly worked.
appreciate your help, thanks again for your time on this!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
@RGC9 You're welcome! I'm glad your problem has been resolved now.