Home > Article > Web Front-end > How to Combine Multiple `onEdit` Trigger Functions in Google Sheets?
Combining Multiple onEdit Trigger Functions
When developing Google Sheets scripts, it is sometimes necessary to use multiple onEdit trigger functions to handle different types of events. However, scripts cannot contain two functions with the same name, which can lead to conflicts. This article demonstrates how to merge or combine multiple onEdit trigger functions into a single function.
Problem:
Consider the following two script functions that are being used to handle different events when a value is edited in a Google Sheet:
function onEdit(e) { // Dependent Dropdown list } function onEdit2(e) { // Add row by checkboxes }
These functions conflict because they both have the same name, onEdit. To resolve this conflict, we need to rename one of the functions and then create a wrapper function named onEdit that calls both of the other functions.
Solution:
function onEditDependentDropdownList(e) { // Dependent Dropdown list }
function onEdit(e) { onEditDependentDropdownList(e); onEdit2(e); }
This wrapper function can be called by the onEdit trigger, which will execute both of the other functions.
Benefits:
Combining multiple onEdit trigger functions into a single function has several benefits:
Related Resources:
The above is the detailed content of How to Combine Multiple `onEdit` Trigger Functions in Google Sheets?. For more information, please follow other related articles on the PHP Chinese website!