I 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+"))");
}
Best Answer
It's very likely that you are running the
onformsubmit
function from the script editor which don't send an event object (e
).In order to run
osformsubmit
from the Google Apps Editor for debugging purposes, you have to create a an auxiliary function to create 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