0
votes

Is it possible to handle multiple onFormSubmit events in the same spreadsheet? I have multiple forms linked to the same sheet effectively used as a database/webapp.

Here is the 'schema'

// first sheet
| client_id | name | is_something | is_another |
|-----------|------|--------------|------------|
| 1         | abc  | no           | no         |

// second sheet
| client_id | event |
|-----------|-------|
| 1         | value |

The use case is that one person in the org is gonna enter the data for the first sheet and another person will periodically look at all entries that don't have the "event" done yet and enter them when they are. At this point the first sheet needs updated to reflect the new boolean value. There are multiple forms that are submitted after the initial that need to update a column on the first sheet.

Is there a better way of doing this? Maybe app script web app? Eventually I'd migrate to App Maker but that isn't a general release yet.

1
you can put the onFormSubmit into the individual forms rather than the spreadsheet.Robin Gertenbach
also the form submit event has a source property that you could useRobin Gertenbach
I wasn't sure if I could modify another file w/ a bound scriptAdam
Absolutely, you actually have to explicitly specify that you want to disable it if you don't want to prevent it.Robin Gertenbach

1 Answers

1
votes

I have tested this, works fine:

function onFormSubmit(){
  var as = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  switch(as.getName()){
    case "sheet_name_1":
      Logger.log("hi sheet 1 !");
      break;
    case "sheet_name_2":
      Logger.log("hi sheet 2 !");          
      break;
  }
}

change the sheet_name to your own sheet name and see if it works :D