1

I have this simple code that i'm using for testing. I have an "on Form submit" installable trigger on my spreadsheet that runs every time a form is submitted. I need to know the range where the response was copied and the responses.

So, i'm using this code

function myFunction(event) {
var Response=event.values
var Rango=event.range
var Row=Rango.getRow()
}

The event.values works properly but the event.range does not. Insted of getting a object Range it's returning object Object.

This is what the error says

TypeError: Cannot find function getRow in object [object Object]. (line 4, file "Code")

It's pretty weird because the code worked properly before.

To be more specific:

  • I'm testing this by submitting the form.
  • I know that the event.values works fine because i added a line of code to send me an email with the event.values and event.range content.
  • Actually, i could access to the content of this object Object by using Range["rowEnd"]. But before i could simply use Range.getRow() because this Range variable was indeed a Range object.

This is the spreadsheet link: https://docs.google.com/spreadsheets/d/1G6fXTkcbibxUZ29cxVTwkNzL5nircsIz2F573IXIUf4/edit?usp=sharing

this is the form link:https://docs.google.com/forms/d/e/1FAIpQLScvHD13JVpMHh3eikRseBbOu6OYlkacK_mkMotVJi9bI_MK0g/viewform?usp=sf_link

Update: After several weeks of trying a lot of things i just realized that is a permission bug (i guess) i reseted all permissions from the security panel of my google account and granted permissions again and DONE.

Ricotero
  • 13
  • 4
  • How are you testing this? – Diego Apr 14 '18 at 17:27
  • Possible duplicate of [How can I test a trigger function in GAS?](https://stackoverflow.com/questions/16089041/how-can-i-test-a-trigger-function-in-gas) – Rubén Apr 14 '18 at 23:50
  • Thanks Diego. I added a line of code to send me an email with the content of Response and Range. As i said before the event.values works but the event.Range does not. – Ricotero Apr 15 '18 at 01:00
  • Thanks Ruben, i am testing this by submitting the form. I know that if i run this code there will be no event. The problem is the event.range is not returning a Range. – Ricotero Apr 15 '18 at 01:03
  • I can't reproduce this, even when using `var Range = e.range;` with my test form and the function: `function logFormSubmitObject(e) { Logger.log(e); var modified = e.range; Logger.log(modified); var Range = e.range; Logger.log(Range); }`: this yields `[18-04-16 18:47:59:365 PDT] {authMode=FULL, values=[4/16/2018 20:47:59, ], namedValues={Test Question=[], Timestamp=[4/16/2018 20:47:59]}, range=Range, source=Spreadsheet, triggerUid=735684595} [18-04-16 18:47:59:365 PDT] Range [18-04-16 18:47:59:366 PDT] Range` – tehhowch Apr 17 '18 at 01:49
  • Thnaks @tehhowch, i added the spreadsheet and form links. – Ricotero Apr 17 '18 at 15:33
  • Those links both go to the form, one in edit one in view, the spreadsheet linked to the form is not shared. – Jared Pinkham Apr 17 '18 at 20:50
  • @JaredPinkham, my bad. I updated the spreadsheet link.The spreadsheet has the test script in it. The form is just to trigger the script, so i don't think that the edit mode is needed. – Ricotero Apr 17 '18 at 23:33
  • JS uses ; as a line terminator. In your script each line that starts with var add a ; to the end and try that. – Jared Pinkham Apr 18 '18 at 12:24
  • @JaredPinkham read about ASI and Javascript – tehhowch May 18 '18 at 05:02
  • @tehhowch coming from a background where white space is ignored and ; are mandatory i find ASI to be a source of bugs and know enough about it to keep it from adding ; where i don't want them. I will admit this can be a handy cap at times, noteably in this case. – Jared Pinkham May 24 '18 at 20:28

0 Answers0