Apps Script 트리거는 지정된 이벤트가 발생할 때마다 지정된 스크립트 함수 (트리거 함수)를 실행합니다. 특정 이벤트만 트리거를 실행할 수 있으며 각 Google Workspace 애플리케이션은 서로 다른 이벤트 집합을 지원합니다.
트리거가 실행되면 이벤트 객체가 생성됩니다. 이 JSON 구조에는 발생한 이벤트에 관한 세부정보가 포함됩니다. 이벤트 객체 구조의 정보는 트리거 유형에 따라 다르게 구성됩니다.
이벤트 객체가 생성되면 Apps Script는 이를 트리거 함수에 매개변수로 전달합니다. 트리거 함수는 이벤트에 응답하는 데 적절한 조치를 취하기 위해 직접 구현해야 하는 콜백 함수입니다. 예를 들어 Gmail을 확장하는 Google Workspace 부가기능에서 사용자가 메시지 대화목록을 열 때 새 카드 인터페이스를 만드는 트리거를 정의할 수 있습니다. 이 경우 문맥 콜백 함수를 구현하여 이벤트 객체에 전달된 데이터를 사용하여 새 UI를 구성하는 카드를 만듭니다.
이 페이지에서는 Google Workspace 부가기능 프로젝트에서 트리거를 사용하는 방법에 관한 가이드라인을 제공합니다.
매니페스트 트리거
편집기 부가기능과 달리 Google Workspace 부가기능은 현재 Apps Script 간단한 트리거를 사용할 수 없습니다. 대신 Google Workspace 부가기능용으로 특별히 설계된 트리거인 매니페스트 트리거를 사용합니다.
매니페스트 트리거는 Google Workspace 부가기능의 manifest에 완전히 정의됩니다. 매니페스트 트리거의 예는 다음과 같습니다.
부가기능 홈페이지를 빌드하고 표시하는 홈페이지 트리거
캘린더 일정이 열릴 때 새 카드를 표시하거나 다른 작업을 실행하는 Calendar eventOpen 트리거
사용자가 Calendar 일정을 수정하고 저장할 때 새 카드를 표시하거나 다른 작업을 실행하는 Calendar eventUpdate 트리거
사용자가 Drive에서 하나 이상의 파일 또는 폴더를 선택할 때 새 카드를 표시하거나 다른 작업을 실행하는 Drive onItemsSelected 트리거
사용자가 Gmail 작성 창에서 부가기능을 열 때 부가기능 카드를 표시하는 Gmail 작성 트리거
사용자가 Gmail 메일을 열 때 새 카드를 표시하거나 다른 작업을 실행하는 Gmail 문맥 트리거
사용자가 현재 편집기 문서에서 drive.file OAuth 범위에 대한 승인을 부여할 때 새 카드를 표시하는 편집기 onFileScopeGranted 트리거
위 목록에서 홈페이지 트리거만 컨텍스트가 아닙니다. 나머지는 컨텍스트 트리거입니다. 매니페스트 트리거 정의에 관한 자세한 내용은 매니페스트를 참고하세요.
Google Workspace 부가기능은 메니페스트 트리거 외에도 Apps Script 설치 가능한 트리거를 사용할 수 있습니다.
제한사항
매니페스트 트리거에는 사용에 관한 몇 가지 제한사항이 있습니다.
이러한 트리거는 Google Workspace 부가기능 프로젝트에서만 사용되며 다른 애플리케이션에서는 아무런 목적도 없습니다.
이러한 트리거는 코드가 아닌 부가기능 매니페스트에 정의되므로 Apps Script Script 서비스를 사용하여 이러한 트리거를 만들거나 수정할 수 없습니다.
현재 Gmail 문맥 트리거에는 unconditional 기준만 사용할 수 있습니다.
즉, 콘텐츠와 관계없이 모든 이메일 메시지에 대해 문맥 트리거가 실행됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-02-16(UTC)"],[[["Apps Script triggers execute a specific function when a defined event occurs within a Google Workspace application."],["Google Workspace add-ons utilize manifest triggers, defined in the add-on's manifest, to respond to events like opening a document or composing an email."],["Manifest triggers can be contextual, reacting to specific user actions within a document or application, or non-contextual, like those that build the add-on's homepage."],["While manifest triggers offer event-driven functionality, they have limitations, including restrictions on their use and creation methods."]]],["Apps Script triggers initiate a script function when specific events occur, creating an event object with event details. This object is then passed to a user-implemented trigger function, enabling actions based on the event. Google Workspace add-ons use manifest triggers, defined in the add-on's manifest, to trigger actions like displaying cards on homepage, when opening/updating Calendar events, selecting Drive items, or opening a message in Gmail. Contextual triggers and installable triggers are also supported but with some restrictions.\n"]]