How to turn off Visibility of top level fields only?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 12:25 PM
In client script I wanted to turn off all fields until such time as they are necessary, as determined by the user selecting a particular Category value, so I write this function:
function makeAllFieldsNotVisible() {
var allFields = g_form.getEditableFields();
for (var i = 0; i < allFields.length; i++) {
if (allFields[i] !== 'u_category') {
g_form.setVisible(allFields[i], false);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 01:55 PM
Hi G24,
Have you looked at the item_option_new table? In my PDI it lists the variable along with the associated catalog item and what variable set it belongs to (if any). Maybe you could create an ajax call that gets called from your client script and goes to that table and checks the variables for that specific catalog item. Since you have 57 variables to check that is a lot of individual ajax calls so I would consider combining all the variables into an array and passing that as a parameter. On your callback function you would need to parse out whether each of those 57 variables should be shown or not, based on whether it belongs to a variable set.
Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2025 02:37 PM
I am wondering why you have 57 fields on your form. This sounds like the bigger issue to me. Can you share a bit more about what you're doing with this long form? Why are you using a client script rather than a UI Policy?