Last commit before activation

This commit is contained in:
Moritz Graf 2026-04-25 13:58:01 +02:00
parent d7c89fda4e
commit 0a65f0f092
3 changed files with 17 additions and 2 deletions

View File

@ -15,4 +15,4 @@ It automates the creation of email forwarding in Google Workspace by reading fro
1. **Never alter the `GROUP_DESCRIPTION_TAG` logic.**
The script achieves declarative state management by finding and deleting Workspace Groups that are NOT present in the Google Sheet. To prevent the catastrophic deletion of real, human-managed groups (e.g., `board@haumdaucher.de`), the script relies on the `[Auto-Forwarder] Managed by Google Sheets` string in the group's description. The script must ALWAYS filter for this exact string before issuing any deletion API calls.
2. **Always deploy via `clasp`.** Do not instruct the user to copy-paste code manually if `clasp` is available.
3. **Trigger:** We use an `onChange` trigger instead of `onEdit` because the source sheet is populated automatically via Google Forms. `onEdit` does not fire on Form submissions.
3. **Trigger:** We use a combination of `onFormSubmit` (for Google Forms) and `onChange` (for manual sheet edits) triggers. This ensures reconciliation happens regardless of how the data was updated.

View File

@ -84,3 +84,12 @@ Once you have reviewed the dry-run execution logs and verified that the script c
3. Edit the spreadsheet one more time to trigger the live sync.
**You are done!** Whenever a new response is submitted to the configured Google Sheet via Forms, the script will automatically run in the background, reconcile the forwarding groups, and send you an email report.
## Troubleshooting & Analysis
If you find that the script is not triggering when a new form is submitted:
1. **Check Executions:** Run `clasp open-script` and click on the **Executions** tab (the list/bullet icon) in the left sidebar.
- **No entries?** The trigger never fired. You may need to run the `setup()` function again to ensure the triggers are installed.
- **Failed entries?** Click on the failed execution to see the exact error message and stack trace.
2. **Re-Run Setup:** If you have pushed new code or changed your Google Account permissions, always re-run the `setup` function in the Apps Script UI to refresh the background triggers and authorization.
3. **Trigger Source:** Ensure the Google Sheet you are using is the same one linked to your Google Form. The `onFormSubmit` trigger only fires on the specific sheet receiving the form responses.

View File

@ -55,7 +55,13 @@ function setup() {
}
}
// Install the onChange trigger (required for Google Forms integrations)
// Install the onFormSubmit trigger (specifically for Google Forms submissions)
ScriptApp.newTrigger('syncForwardings')
.forSpreadsheet(ss)
.onFormSubmit()
.create();
// Also install an onChange trigger as a fallback (for manual sheet edits)
ScriptApp.newTrigger('syncForwardings')
.forSpreadsheet(ss)
.onChange()