# Formulas affecting Groups of Fields

We'll show you examples where formulas can be applied to change visibility, collpased, Help Text and more.

#### Important: Now using Formulas V2 🆕 in 2sxc 16

Formulas V2 has intellisense, stoppability, support for promises and more.

##
Group visibility

### Try it:

This formula determines the visibility of the Advanced settings group. The group becomes visible, when the Advanced toggle is active.

*Click on the (Σ) button above to see the edit-UI with the formula.*

### Formulas of `FormulasVisibleGroup.AdvancedSettings`

**Field.Settings.Visible** (Formula-Target: Field.Settings.Visible)

v2((data) => { return data.Advanced == true; });

##
Group Name - Text summary

### Try it:

This formula changes the Name of the PersonGroup field. The name becomes **Person - Profile complete** if all group fields are filled out and **Person - Profile incomplete** if not.

*Click on the (Σ) button above to see the edit-UI with the formula.*

### Formulas of `FormulasTextSummary.PersonGroup`

**Field.Settings.Name** (Formula-Target: Field.Settings.Name)

v2((data) => { if (data.Firstname != "" && data.Lastname != "" && data.Address != "") return "Person - Profile complete"; return "Person - Profile incomplete" });

##
Group Name - Emoji summary

### Try it:

This formula changes the Name of the ProductGroup field. The name becomes "Product ✅" if all group fields are filled out and "Product ✏️" if not.

*Click on the (Σ) button above to see the edit-UI with the formula.*

### Formulas of `FormulasEmojiSummary.ProductGroup`

**Field.Settings.Name** (Formula-Target: Field.Settings.Name)

v2((data) => { if (data.Name != "" && data.Pricing != null) { return "Product ✅"; } return "Product ✏️"; });

##
Helptext

### Try it:

`prefill:ProductCode=n0t0k code`

`prefill:`

This formula adds a help text based on the ProductCode Field text. If the ProductCode field contains **n0t0k** the helptext gets this added: *This product code is deprecated. Please request a new product code.* If it contains **spaces** the helptext gets this added: *Please remove all spaces from your product code*.

*Click on the (Σ) button above to see the edit-UI with the formula.*

### Formulas of `FormulasHelpText.ProductCode`

**Setting Notes** (Formula-Target: Field.Settings.Notes)

v2((data) => { const isDeprecated = data.ProductCode.includes("n0t0k"); const hasSpaces = data.ProductCode.includes(" "); return (isDeprecated ? "This product code is deprecated. Please request a new product code. " : "") + (hasSpaces ? "Please remove all spaces from your product code." : ""); });

##
Run Code Only when Form Opens

### Try it:

This formula determines the initial open/closed state - in this case randomly. Normally it would do this based on how complete data in that section is or based on other criterias.

This is often used to improve initial state of a form based on how much data is already filled in.

*Click on the (Σ) button above to see the edit-UI with the formula.*

### Formulas of `FormulasRunAtStart.GroupRandomlyOpen`

**Field.Settings.Collapsed** (Formula-Target: Field.Settings.Collapsed)

v2(() => { console.log('Formula to set Collapsed ran - will only run once.'); // Get random true/false var random = Math.random() < 0.5; return { value: random, stop: true }; });