Office Script can’t append to a protected worksheet - best practice?
I’m building an Excel Online workbook in Microsoft Teams that uses an Office Script to complete preventive maintenance (PM) records.
Current workflow:
User completes a PM on a “PM Completion” sheet.
Office Script appends a new row to a “PM History” sheet.
The script also creates a Repair Log entry if any checklist item is marked as an issue.
Everything works correctly while the PM History sheet is unprotected.
If I protect the PM History sheet (to prevent users from editing historical records), the Office Script fails when it tries to append the new row.
My goal is to keep PM History as a read-only audit log while still allowing the Office Script to write new records.
My questions are:
Is this an expected limitation of Office Scripts with protected worksheets?
Is there a recommended pattern for this?
Temporarily unprotect and re-protect in the script?
Store data on another sheet and copy it?
Leave history unprotected and rely on workbook permissions?
How are people building protected audit logs in Excel Online/Teams with Office Scripts?
I’d appreciate hearing how others have solved this.