Hi there.
I have been using ChatGPT to try and help me write a script that will automatically trigger when someone submits a new Google form.
A person's coordinates are added to column E, I am needing those coordinates split into 2 separate columns (Column F = latitude, Column G = Longitude)... I have attached an image of what the sheet will look like.
Here is an example of one of the many code examples ChatGPT has done for me, as well as the error code I am getting.
Can anyone help?!
function onFormSubmit(e) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Needs assistance");
var lastColumn = sheet.getLastColumn();
var editedRow = sheet.getLastRow();
var editedValue = e.range.getSheet().getRange(e.range.getRow(), 5).getValue(); // Adjusted for column E
// Split the edited value by a comma (",")
var splitValues = editedValue.split(",");
// Clear the edited cell
sheet.getRange(editedRow, lastColumn).clearContent();
// Get the range for the split values
var splitRange = sheet.getRange(editedRow, lastColumn + 1, 1, splitValues.length);
// Set the split values to the range
splitRange.setValues([splitValues]);
}
Error
TypeError: Cannot read properties of undefined (reading 'source')