Skip to main content

Overview

SGD-MCS uses a centralized configuration system defined in Backend/core/config.js. All configuration constants, database mappings, and color schemes are defined here and automatically available across all Google Apps Script files.
The configuration file is loaded globally, so all constants are accessible in every .gs file without imports.

Core Configuration

Database Connection

SPREADSHEET_ID
string
required
The Google Sheets spreadsheet ID that serves as the database.
const SPREADSHEET_ID = '13DnE1bamQgWQ2G5cuGq9vdlP-tHu6QgdBtZptqKkLuc';
Location: Backend/core/config.js:11
This is the most critical configuration value. If changed, the system will connect to a different database. Always back up before modifying.
ROOT_FOLDER_ID
string
default:""
The Google Drive folder ID where all system files are stored.
const ROOT_FOLDER_ID = '1vlf1dwjSDa6pirU80HhCexpYvCOetWeb';
Location: Backend/core/config.js:14If left empty, the system will create a folder named SGD_DATABASE_ROOT in the user’s Drive root.

Sheet Mappings

The SHEETS object maps logical entity names to actual Google Sheets tab names:
SHEETS
object
const SHEETS = {
    ESTUDIANTES: 'Estudiantes',
    DOCENTES: 'Docentes',
    EXTERNOS: 'ParticipantesExternos',
    INSTITUCIONES: 'Instituciones',
    TESIS: 'Tesis',
    EVENTOS: 'Eventos',
    PARTICIPACIONES: 'Participaciones',
    HISTORIAL: 'Historial_Documentos',
    CONFIG: 'Configuracion'
};
Location: Backend/core/config.js:19-33

Sheet Structure

ConstantTab NamePurpose
ESTUDIANTESEstudiantesStudent records
DOCENTESDocentesFaculty/advisor records
EXTERNOSParticipantesExternosExternal participants
INSTITUCIONESInstitucionesPartner institutions
TESISTesisThesis records
EVENTOSEventosAcademic events
PARTICIPACIONESParticipacionesEvent participation (M:N relation)
HISTORIALHistorial_DocumentosDocument audit trail
CONFIGConfiguracionSystem counters and settings
Do not rename sheet tabs directly in Google Sheets. Update the SHEETS constant in config.js to maintain consistency.

Color Palette

The system uses a predefined color scheme for visual consistency:
const COLORS = {
    ESTUDIANTES: '#4285F4',    // Google Blue
    DOCENTES: '#FF9800',       // Orange
    TESIS: '#9C27B0',          // Purple
    EVENTOS: '#E91E63',        // Pink
    INSTITUCIONES: '#009688',  // Teal
    EXTERNOS: '#8BC34A',       // Light Green
    PARTICIPACIONES: '#607D8B', // Blue Grey
    HISTORIAL: '#3F51B5',      // Indigo
    CONFIG: '#263238'          // Dark Grey
};
Location: Backend/core/config.js:38-50 These colors are applied when regenerating the database structure using the Setup script.

Utility Functions

getDB()

Returns the database spreadsheet instance:
function getDB() {
    return SpreadsheetApp.openById(SPREADSHEET_ID);
}
Usage: Use this instead of SpreadsheetApp.openById() throughout your code.

getAppConfig()

Returns the complete configuration object for the frontend:
function getAppConfig() {
    return {
        appVersion: '3.0.0',
        environment: 'Production',
        sheets: SHEETS,
        colors: COLORS
    };
}

Time Zone Configuration

The system timezone is configured in appsscript.json:
{
  "timeZone": "America/Bogota"
}
Location: Backend/appsscript.json:2 All timestamps use this timezone for consistency.

Environment Variables

1

Set Spreadsheet ID

Update SPREADSHEET_ID in config.js with your Google Sheets database ID.
2

Configure Drive Folder

Update ROOT_FOLDER_ID with your Google Drive folder ID, or leave empty for auto-creation.
3

Deploy Script

Push changes to Google Apps Script using clasp or the web editor.
4

Verify Setup

Test configuration by calling getAppConfig() from the Apps Script editor.

Best Practices

Always commit configuration changes to version control with clear documentation of what changed and why.
Use separate spreadsheets and folders for development, staging, and production environments.
Create a backup copy of the spreadsheet before modifying critical configuration values.
After changing configuration, test all CRUD operations to ensure connectivity.

Troubleshooting

Database Connection Failed

Symptom: Functions return errors about missing spreadsheetSolution: Verify SPREADSHEET_ID is correct and the service account has access.

Drive Folder Not Found

Symptom: Files cannot be uploaded or organizedSolution: Check ROOT_FOLDER_ID exists and has proper permissions, or set to empty string for auto-creation.

Sheet Not Found

Symptom: Operations fail with “Sheet not found” errorsSolution: Ensure all sheet names in SHEETS constant match actual tab names in the spreadsheet exactly.

Next Steps

Database Structure

Learn about the database schema and sheet structure

Google Apps Script

Deploy and manage the Apps Script backend

Build docs developers (and LLMs) love