2

trigger installedI am getting this error when running :TypeError: Cannot read property 'range' of undefined at onformsubmit(Code:10:17) I have installed the onformsubmit trigger but it is not working. What is not working here?

function onformsubmit(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var range = e.range;
  var row = range.getRow();
  var sheet = range.getSheet();

  sheet.getRange(row, 17).setFormula("=if($O"+row+"=\"UZS\",index(googlefinance(\"currency:UZSUSD\",\"price\",$B"+row+"),2,2)*$P"+row+",if($O"+row+"=\"EUR\",index(googlefinance(\"currency:EURUSD\",\"price\",$B"+row+"),2,2)*$P"+row+",$P"+row+"))");
}

1 Answer 1

1

It's very likely that you are running the onformsubmit function from the script editor which don't send an event object (e).

Note: The same happens with any function that use an object as parameter that use an object property, no matter of the property name.

In order to run onformsubmit or any other function that requires an object as parameter from the Google Apps Editor for debugging purposes, you have to create a an auxiliary function to mock the event object and assign the required properties. For a broader explanation see the answer from Mogsdad to How can I test a trigger function in GAS?

Related

2
  • even though I have created the event object the very error is occurring again Mar 25, 2020 at 15:29
  • @AroonAdvisoryGroup Please create a new question including enough details to understand how do you created the event object and how you are using it. Mar 25, 2020 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.