# Form Submit Not Triggering Google Scripts

**URL:** https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192
**Category:** Ask for Help
**Created:** [June 21, 2020, 4:52am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192 "2020-06-21T04:52:35Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 4:52am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/1 "2020-06-21T04:52:35Z")

</div>

I am trying to get google sheets to trigger a onEdit script when a form is submitted by identifying when a column changes. I can type in the column and it triggers the script but when I have a form submit data to the column it does not trigger. Any ideas.

Here is the script I’m running:

function onEdit(e) {  
var langName = ‘ADVISOR INFORMATION’  
var langCell = ‘C2’  
var curSheet = e.range.getSheet()

if (curSheet.getName() === langName) {  
if (e.range.getA1Notation() === langCell) {  
var cookingMethodSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘APPOINTMENTS’)  
var range = cookingMethodSheet.getRange(‘D2:N2’)  
range.clear()  
}  
}  
}

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [June 21, 2020, 5:01am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/2 "2020-06-21T05:01:55Z")

</div>

Hi Joe, is this the problem?

> [@onEdit() script won't run when sheet is edited by Glide app](https://community.glideapps.com/t/onedit-script-wont-run-when-sheet-is-edited-by-glide-app/8850/2):
>
> Hi Rogelio, As I have discussed here, onEdit() won’t work with Glide. Change it to onChange(), or trigger the event by an “on change” option in the triggers dashboard.

---

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 5:04am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/3 "2020-06-21T05:04:36Z")

</div>

The problem with onChange() is that it would be performed everytime something in the workbook is changed not just the sheet the forms are submitted to. Unless I’m mistaken and you can do a onchange with just a single sheet

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [June 21, 2020, 5:06am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/4 "2020-06-21T05:06:39Z")

</div>

Wrap a further IF to make sure it only triggers for a certain sheet.

For example:

```
function sendEmail(e) {
   var Active = e.source.getActiveSheet().getName();
    if(Active == 'SheetA'){
```

---

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 5:07am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/5 "2020-06-21T05:07:07Z")

</div>

What I meant to say is that I don’t think it’s possible to setup onChange to just look at one tab and not the entire workbook/sheet.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [June 21, 2020, 5:08am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/6 "2020-06-21T05:08:00Z")

</div>

Yeah I understood that. You can try my method above, wrap an IF so that it is only triggered when the active sheet is the sheet of your choice.

---

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 5:11am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/9 "2020-06-21T05:11:12Z")

</div>

Taking my original script above could you try to modify it with on change and I can see if it works.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [June 21, 2020, 8:12am UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/10 "2020-06-21T08:12:02Z")

</div>

> function ClearRows(e) {  
> var Active = e.source.getActiveSheet().getName();  
> if(Active == ‘ADVISOR INFORMATION’){  
> var langCell = ‘C2’
> 
> if (e.range.getA1Notation() === langCell) {  
> var cookingMethodSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘APPOINTMENTS’)  
> var range = cookingMethodSheet.getRange(‘D2:N2’)  
> range.clear()  
> }  
> }  
> }  
> }

Can you try this and tell me if it works?

---

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 4:27pm UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/11 "2020-06-21T16:27:15Z")

</div>

I’m sorry. I live in the states and it got so late I just took another stab at it and got it working then went to bed. This is the script I made that got it to work though:

function onChange(e) {  
var sheet = e.source.getActiveSheet()  
if (sheet.getName() === ‘ADVISOR INFORMATION’) {  
var cookingMethodSheet =  
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(‘APPOINTMENTS’)  
var range = cookingMethodSheet.getRange(‘D2:N2’)  
range.clear()  
}  
}

Thank you for your help and your time.

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [June 21, 2020, 4:28pm UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/12 "2020-06-21T16:28:18Z")

</div>

No worries, have a nice Sunday yourself. Now my time to go to bed, it’s 11pm in Vietnam 😄

---

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 4:30pm UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/13 "2020-06-21T16:30:11Z")

</div>

It’s pretty much identical to be honest…I just eliminated a variable. And I needed it to check the entire page, I used that variable for testing. That’s the only reason I had it on there.

---

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 4:32pm UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/14 "2020-06-21T16:32:37Z")

</div>

Real quick, do you know if it’s possible to make glide return to the home page/default page after a form is submitted? Even though the form wasn’t native to that page?

---

<div class="post-metadata">

### Author: ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)
#### Post date: [June 21, 2020, 4:41pm UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/15 "2020-06-21T16:41:08Z")

</div>

Just a quick advice: did you double check if your script have any runtime error and it makes you believe that the trigger isn’t fired?

I had the same trouble weeks ago and when I checked the log I could see my big error!!

I hope it helps.

Saludos

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [June 21, 2020, 4:49pm UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/16 "2020-06-21T16:49:33Z")

</div>

It’s not possible at the moment as far as I aware. I want that option as well, not necessarily home screen but a screen of my choice.

---

<div class="post-metadata">

### Author: ![Drearystate](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drearystate/32/49605_2.png) [@Drearystate](https://community.glideapps.com/u/Drearystate)
#### Post date: [June 21, 2020, 5:00pm UTC](https://community.glideapps.com/t/form-submit-not-triggering-google-scripts/11192/17 "2020-06-21T17:00:33Z")

</div>

Yeah, it’s amazing that we can’t.
