← Back to Form Builder

🛠️ Developer Documentation

Technical reference for advanced form building and debugging

🌐 Global Variables System NEW

window.FormVariables
Global variable management system accessible throughout the application.

Methods:

window.FormVariables.set(name, value) // Set a global variable window.FormVariables.get(name) // Get variable value window.FormVariables.has(name) // Check if variable exists window.FormVariables.getAll() // Get all variables as object window.FormVariables.clear() // Clear all variables window.FormVariables.debug() // Console table display

Debug Shortcuts:

window.vars.debug() // Quick debug access window.vars.getAll() // Quick get all variables
Login Variables FIXED
Automatically set after successful Login field authentication.

Available Variables:

isLoggedIn = "true" // Primary login status loggedIn = "true" // Alternative login status userEmail = "user@example.com" // Authenticated email userName = "John Doe" // Contact name or email

Usage in Conditional Logic:

// Show submit button only after login Condition: isLoggedIn equals "true" // Show different content for logged users Condition: userEmail is not empty

🔧 Variables Manager API NEW

showVariablesManager()
Opens the Variables Manager modal for real-time variable monitoring.
window.showVariablesManager();
refreshVariables()
Refreshes the variables list in the modal.
window.refreshVariables();
addVariable()
Programmatically adds a variable via the manager interface.
// Set inputs then call document.getElementById('newVariableName').value = 'testVar'; document.getElementById('newVariableValue').value = 'testValue'; window.addVariable();
exportVariables()
Exports all variables as downloadable JSON file.
window.exportVariables();

📝 Enhanced Form Builder API

setupRequireLoginForButton() NEW
Quick setup for login-required navigation buttons.

Functions:

window.setupRequireLoginForNext() // Require login for Next button window.setupRequireLoginForSubmit() // Require login for Submit button

What it does:

// Automatically creates condition: // Field: isLoggedIn // Condition: equals // Value: "true"
Smart Dropdown Enhancements NEW
Dynamic field loading and variable discovery.

RecordId Variable Options:

// Automatically includes: // - Global variables from FormVariables // - Common patterns (ContactId, AccountId, etc.) // - Login field variables // - Lookup field ID variables // - Option to create custom variables

Relationship Field Options:

// Dynamically loads from Salesforce: // - All reference fields for current object // - Field labels and relationship targets // - Option to create custom field names

🏗️ Module System

window.AppModules
Central access point for all application modules.

Available Modules:

window.AppModules.formBuilder // Form building interface window.AppModules.salesforce // Salesforce integration window.AppModules.conditionalLogic // Conditional visibility window.AppModules.multiPage // Multi-page navigation window.AppModules.autoSave // Auto-save functionality window.AppModules.fieldTypes // Field type handlers window.AppModules.signature // E-signature capture window.AppModules.flowLogic // Email/OTP workflows
Performance Optimizations UPDATED
Auto-save optimizations to reduce server load.

Auto-save Changes:

// OLD: 500ms debounce (causing server overload) // NEW: 3000ms debounce (6x reduction in requests) // Access auto-save instance: window.AppModules.autoSave.autoSaveInterval // Now: 3000ms

👁️ Conditional Logic API ENHANCED

Field Value Priority System
Enhanced priority system for variable/field value resolution.

Priority Order:

// 1. Global Variables (FormVariables) - HIGHEST PRIORITY if (window.FormVariables?.has(fieldId)) { value = window.FormVariables.get(fieldId); } // 2. Field Values - MEDIUM PRIORITY else if (this.fieldValues.get(fieldId)) { value = this.fieldValues.get(fieldId); } // 3. MultiPage Variables - LOWEST PRIORITY else if (window.AppModules.multiPage?.getVariable(fieldId)) { value = window.AppModules.multiPage.getVariable(fieldId); }
Navigation Button Conditional Visibility FIXED
Per-page conditional visibility for Next and Submit buttons.

Configuration Structure:

page.navigationConfig = { next: { conditionalVisibility: { enabled: false, conditions: [ { dependsOn: 'isLoggedIn', condition: 'equals', value: 'true' } ], logic: 'AND' // or 'OR' } }, submit: { /* same structure */ } }

🔗 Salesforce Integration API

Enhanced Record Update Logic IMPROVED
Priority-based record ID resolution for update operations.

Server-side Priority (server.js):

// 1. Page-specific recordIdVariable (NEW - HIGHEST PRIORITY) if (page.recordIdVariable && variables[page.recordIdVariable]) { recordId = variables[page.recordIdVariable]; } // 2. Record data ID fields (MEDIUM PRIORITY) else if (record.Id || record.id) { recordId = record.Id || record.id; } // 3. Common ID patterns (LOWEST PRIORITY - FALLBACK) else if (variables.ContactId || variables.RecordId) { recordId = variables.ContactId || variables.RecordId; }
Multi-Org Security SECURED
Enhanced encryption and org protection.

Security Features:

// Persistent encryption key prevents data loss ENCRYPTION_KEY=your-64-character-hex-key // Dangerous cleanup function disabled cleanupCorruptedOrgs() { // DISABLED - returns safety message return { deletedCount: 0, message: 'Function disabled for safety' }; }

🐛 Debugging Tools

Variable Debugging
Real-time variable inspection and monitoring.
// Console commands window.vars.debug() // Table view window.vars.getAll() // Object view window.FormVariables.variables // Raw Map // Variables Manager UI window.showVariablesManager() // Visual interface
Conditional Logic Debugging
Debug conditional visibility issues.
// Check condition evaluation window.AppModules.conditionalLogic.evaluateAllConditions() // Check field values window.AppModules.conditionalLogic.fieldValues // Check page conditions window.AppModules.conditionalLogic.pageConditions
Enhanced Logging NEW
Comprehensive logging system for troubleshooting.
// Variable discovery logging 📊 Found X global variables for conditional visibility // Login authentication logging 🔐 LOGIN: Setting global variable "isLoggedIn" = "true" // Auto-refresh logging 🔄 Refreshing form builder properties panel for new variables

⚙️ Environment Configuration

Critical Environment Variables
Essential configuration for production deployment.

Required Variables:

# CRITICAL - Prevents org data loss on restart ENCRYPTION_KEY=your-64-character-hex-key-here # Salesforce OAuth SALESFORCE_CLIENT_ID=your-consumer-key SALESFORCE_CLIENT_SECRET=your-consumer-secret # Server Configuration PORT=8080 DOMAIN=your-domain.com SESSION_SECRET=your-session-secret # Auto-save Performance (Optional - defaults to 3000ms) AUTOSAVE_INTERVAL=3000

Generate Encryption Key:

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

🆕 January 2025 Updates

Variables Management System
Complete variable lifecycle management.
✅ Variables Manager modal ✅ Real-time variable monitoring ✅ Manual variable creation ✅ JSON export/import ✅ Debug console integration
Login Variable Integration
Fixed conditional visibility issues.
✅ Auto-refresh properties panel ✅ Login variables in dropdowns ✅ Quick "Require Login" buttons ✅ Real-time UI updates
Smart Dropdowns
Dynamic field discovery and configuration.
✅ RecordId variable picker ✅ Relationship field picker ✅ Salesforce field loading ✅ Custom field creation
Performance & Security
Production-ready optimizations.
✅ 6x auto-save optimization ✅ Persistent encryption keys ✅ Enhanced error handling ✅ Comprehensive logging

📚 Quick Reference

Most Used Developer Functions
Common debugging and development commands.
// Variable Management window.vars.debug() // Show all variables window.FormVariables.set('test', 'value') // Set test variable window.showVariablesManager() // Open Variables Manager // Form Builder Access window.AppModules.formBuilder.getCurrentPage() // Get current page window.AppModules.formBuilder.getFormData() // Get entire form // Conditional Logic Debug window.AppModules.conditionalLogic.evaluateAllConditions() // Quick Login Setup window.setupRequireLoginForNext() // Require login for Next window.setupRequireLoginForSubmit() // Require login for Submit // Auto-save Control window.AppModules.autoSave.saveBuilderData() // Manual save window.AppModules.autoSave.enabled = false // Disable auto-save