Dynamically Hide Field Groups in NetSuite with Client-Side Scripts

By: Bobby Stevens

Field groups are a great way to organize NetSuite forms, making them more user-friendly. However, sometimes you might want to show or hide specific field groups depending on changing conditions on the form. Client-side scripts offer an elegant way to do this without needing multiple forms.

The Code

Here’s a streamlined client-side function to hide a field group, along with explanations:

JavaScript

function hideFieldGroup(fieldGroupTitle) {
  // Get a reference to the field group's table element 
  const fieldGroupTable = document.querySelector('[data-walkthrough="FieldGroup:' + fieldGroupTitle + '"]'); 

  // If the field group is found, hide it
  if (fieldGroupTable) {
    fieldGroupTable.style.display = 'none'; 
  }
}

// Example usage: Hide the 'Sales Forecast' field group
hideFieldGroup('Sales Forecast'); 

How it Works

  1. Targeting the Element: The code targets the field group using a CSS selector.
  2. Hiding: Once the correct element is found, its display style is set to none to hide it.

When to Use This

  • Conditional Display: Based on values in other fields, you might determine a field group is no longer relevant.
  • Sublist Changes: If a sublist is modified (e.g., an item is removed), you might hide field groups related to that item.
  • Streamlined Workflow: Hide fields that are initially irrelevant and reveal them only when needed.

Need Help? Let’s Connect!

I’m a certified NetSuite developer dedicated to making NetSuite work seamlessly for businesses. If you have any NetSuite development requirements, I’d be delighted to assist! Please feel free to reach out.

← Back

Thank you for your response. ✨

Warning
Warning
Warning
Warning.