> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.swellsystem.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Conditional Logic

# Conditional Logic

Use conditional logic to create dynamic, personalized forms that adapt based on user responses.

## What is Conditional Logic?

Conditional logic allows you to:
- Show or hide fields based on answers
- Skip to specific questions
- Change field options dynamically
- Enable/disable fields based on other fields
- Calculate values based on other fields

## Show/Hide Fields

### Basic Show/Hide

Show a field only when another field has a specific value:

**Example:**
```
IF "Are you interested in our premium plan?" EQUALS "Yes"
THEN SHOW "Premium Plan Details" field
ELSE HIDE "Premium Plan Details" field
```

### Multiple Conditions

Combine multiple conditions with AND/OR logic:

**Example:**
```
IF "Country" EQUALS "United States" AND "State" EQUALS "California"
THEN SHOW "California-Specific Information" field
```

**OR Logic:**
```
IF "How did you hear about us?" EQUALS "Social Media" OR "How did you hear about us?" EQUALS "Referral"
THEN SHOW "Referral Code" field
```

## Jump Logic

Skip to specific questions or sections based on answers.

### Skip to Question

Jump to a specific question:

**Example:**
```
IF "Are you a returning customer?" EQUALS "Yes"
THEN JUMP TO "Customer ID" question
ELSE CONTINUE TO NEXT QUESTION
```

### Skip Section

Skip entire sections:

**Example:**
```
IF "Do you need technical support?" EQUALS "No"
THEN SKIP "Technical Details" section
ELSE CONTINUE TO "Technical Details" section
```

### End Form Early

End the form based on answers:

**Example:**
```
IF "Are you eligible for our service?" EQUALS "No"
THEN END FORM (show "Not Eligible" message)
ELSE CONTINUE
```

## Field Dependencies

### Enable/Disable Fields

Enable or disable fields based on other fields:

**Example:**
```
IF "Payment Method" EQUALS "Credit Card"
THEN ENABLE "Credit Card Number" field
ELSE DISABLE "Credit Card Number" field
```

### Dynamic Options

Change field options based on other fields:

**Example:**
```
IF "Country" EQUALS "United States"
THEN SHOW US States in "State" dropdown
ELSE IF "Country" EQUALS "Canada"
THEN SHOW Canadian Provinces in "State" dropdown
```

## Calculation Logic

Calculate values based on other fields.

### Simple Calculations

**Example:**
```
Total = Quantity × Price
```

### Conditional Calculations

**Example:**
```
IF "Customer Type" EQUALS "Business"
THEN Total = Quantity × Price × 0.9 (10% discount)
ELSE Total = Quantity × Price
```

### Running Totals

Keep a running total as user fills form:

**Example:**
```
Total = Sum of all "Item Price" fields
```

## Condition Operators

### Comparison Operators

- **Equals** (=): Field value equals specified value
- **Not Equals** (≠): Field value does not equal specified value
- **Contains**: Field value contains specified text
- **Does Not Contain**: Field value does not contain specified text
- **Greater Than** (>): Field value is greater than specified value
- **Less Than** (<): Field value is less than specified value
- **Greater Than or Equal** (≥): Field value is greater than or equal
- **Less Than or Equal** (≤): Field value is less than or equal

### Special Operators

- **Is Empty**: Field has no value
- **Is Not Empty**: Field has a value
- **Is One Of**: Field value is in a list of values
- **Is Not One Of**: Field value is not in a list of values

## Setting Up Conditional Logic

### Step 1: Add Logic Rule

1. Select the field you want to control
2. Click **"Add Logic"** or **"Conditional Logic"**
3. Choose logic type (Show/Hide, Jump, etc.)

### Step 2: Define Condition

1. Select the field to check
2. Choose operator (Equals, Contains, etc.)
3. Enter the value to compare

### Step 3: Set Action

1. Choose what happens when condition is met
2. Configure action details
3. Set what happens when condition is not met

### Step 4: Test Logic

1. Preview form
2. Test different answer combinations
3. Verify logic works correctly

## Advanced Logic

### Nested Conditions

Create complex logic with nested conditions:

**Example:**
```
IF "Customer Type" EQUALS "Business"
  THEN IF "Company Size" GREATER THAN 100
    THEN SHOW "Enterprise Features" field
    ELSE SHOW "Standard Features" field
  ELSE SHOW "Individual Features" field
```

### Multiple Actions

Apply multiple actions based on one condition:

**Example:**
```
IF "Priority" EQUALS "Urgent"
THEN:
  - SHOW "Urgent Contact" field
  - SET "Assigned To" to "Support Manager"
  - SET "Status" to "High Priority"
```

## Best Practices

1. **Keep It Simple**: Start with simple logic, add complexity gradually
2. **Test Thoroughly**: Test all possible answer combinations
3. **Clear Conditions**: Use clear, understandable conditions
4. **Avoid Loops**: Don't create circular dependencies
5. **Document Logic**: Document complex logic for future reference
6. **User Experience**: Ensure logic improves, not hinders, user experience

## Common Use Cases

### Qualification Forms

Show relevant questions based on qualifications:

```
IF "Annual Revenue" GREATER THAN 1000000
THEN SHOW "Enterprise Plan" questions
ELSE SHOW "Standard Plan" questions
```

### Multi-Step Forms

Skip steps based on answers:

```
IF "Do you need setup assistance?" EQUALS "No"
THEN SKIP "Setup Preferences" step
ELSE CONTINUE TO "Setup Preferences" step
```

### Dynamic Pricing

Calculate prices based on selections:

```
Base Price = 100
IF "Add Premium Support" EQUALS "Yes"
THEN Total = Base Price + 50
ELSE Total = Base Price
```

## Troubleshooting

### Logic Not Working

- Check condition values match exactly
- Verify field keys are correct
- Test with different answer combinations
- Check for conflicting logic rules

### Fields Not Showing/Hiding

- Verify logic rules are active
- Check condition operators
- Ensure field dependencies are correct
- Review form preview

### Jump Logic Issues

- Verify target question exists
- Check question order
- Ensure no circular jumps
- Test jump paths