Clark Counselor Notification System

Version: 2.0.0 | Author: Alvaro Gomez | Project Lead: Wendy Gomez

📚 Table of Contents

📋 Overview

Automated email notification system that processes Google Form submissions and sends counselor requests to appropriate staff members based on student information and request urgency levels.

🚀 Main Functions

onFormSubmit(e)

Description: Main form submission handler and email dispatcher. Processes Google Form submissions, validates data, determines appropriate counselor routing, sends email notifications, and updates spreadsheet checkboxes.

Parameters:
@param {Object} e - Form submission event object from Google Forms
@param {Array<string>} e.values - Array of form response values
Throws:
@throws {Error} When counselor email mapping is not found
@throws {Error} When form validation fails
Example:
const mockEvent = {
  values: ['timestamp', 'student@email.com', 'Gomez (Cas-Fl)', '12345', 'Doe', 'John']
};
onFormSubmit(mockEvent);
@since 1.0.0
addCheckboxesToCounselorSheets()

Description: Adds checkboxes to column K starting in row 2 for specified counselor sheets. Iterates through predefined counselor sheet names and adds checkboxes for tracking completed requests.

Throws:
@throws {Error} When spreadsheet access fails or sheet operations error
Example:
// Called automatically on form submission
addCheckboxesToCounselorSheets();
@since 2.0.0

✅ Validation Functions

validateFormEvent(e)

Description: Validates the form submission event to ensure it contains required data.

Parameters:
@param {Object} e - Form submission event object
Returns:
@returns {boolean} True if valid, false otherwise
validateFormData(formData)

Description: Validates required form data fields including firstName, lastName, counselorName, and reason.

Parameters:
@param {Object} formData - Parsed form data
Returns:
@returns {boolean} True if valid, false otherwise
parseFormData(values)

Description: Parses form data into a structured object with named properties instead of array indices.

Parameters:
@param {Array} values - Form response values
Returns:
@returns {Object} Parsed form data with structured properties

📧 Email Functions

composeEmail(formData)

Description: Composes the email subject and body with improved formatting and clear sections.

Parameters:
@param {Object} formData - Parsed form data
Returns:
@returns {Object} Email data with subject and body properties
sendRegularEmail(emailData, counselorEmail)

Description: Sends regular email to specific counselor with both plain text and HTML formatting.

Parameters:
@param {Object} emailData - Email subject and body
@param {string} counselorEmail - Target counselor email address
sendEmergencyEmail(emailData, allEmails)

Description: Sends emergency email to all counselors when urgent requests are submitted.

Parameters:
@param {Object} emailData - Email subject and body
@param {Array} allEmails - Array of all counselor email addresses

🔧 Utility Functions

isEmergencyRequest(formData)

Description: Determines if the request is an emergency requiring all counselors to be notified.

Parameters:
@param {Object} formData - Parsed form data
Returns:
@returns {boolean} True if emergency, false otherwise
buildReasonSpecificContent(formData)

Description: Builds reason-specific email content with better formatting for different request types.

Parameters:
@param {Object} formData - Parsed form data
Returns:
@returns {string} Formatted reason-specific content
sendErrorNotificationEmail(error)

Description: Sends error notification email to administrator when script execution fails.

Parameters:
@param {Error} error - The error object to report

⚙️ Configuration

CONFIG

Description: Main configuration object containing admin email, form column indices, and system settings.

Properties:
CONFIG = {
  ADMIN_EMAIL: 'alvaro.gomez@nisd.net',
  EMAIL_SUBJECT: 'REQUEST TO SEE COUNSELOR',
  EMERGENCY_URGENCY: 'Red (It is an emergency...)',
  FORM_COLUMNS: {
    STUDENT_EMAIL: 1,
    COUNSELOR_NAME: 2,
    STUDENT_ID: 3,
    // ... more columns
  }
}
COUNSELOR_EMAILS

Description: Email mapping configuration with separate PRODUCTION and TESTING environments.

Usage:
// Switch between environments
const counselorEmails = COUNSELOR_EMAILS.TESTING; // or .PRODUCTION
REASON_TYPES

Description: Predefined constants for counselor request reason types to ensure consistency.

Available Types:
REASON_TYPES = {
  ACADEMIC: 'Academic (4 Year Planning...)',
  SCHEDULING: 'Scheduling Concerns...',
  PERSONAL: 'Personal Issues',
  COLLEGE_CAREER: 'College & Career Planning...',
  OTHER: 'Other'
}

Generated on July 26, 2025 | Clark Counselor Notification System v2.0.0