I had set up a code previously but it was deleted by someone on our team but now I can't seem to get it working. I need the google forms to automatically add the link to edit the form to the google sheet when a form is submitted.
function createFormTrigger() {
var triggerName = 'addFormResponseUrl';
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
ScriptApp.newTrigger(triggerName).forSpreadsheet(spreadsheet).onFormSubmit().create();
}
function addFormResponseUrl(e) {
// Get the Google Form linked to the response
var responseSheet = e.range.getSheet();
var googleFormUrl = responseSheet.getFormUrl();
var googleForm = FormApp.openByUrl(googleFormUrl);
// Get the form response based on the timestamp
var timestamp = new Date(e.namedValues.Timestamp[0]);
var formResponse = googleForm.getResponses(timestamp).pop();
// Get the Form response URL and add it to the Google Spreadsheet
var responseUrl = formResponse.getEditResponseUrl();
var row = e.range.getRow();
var responseColumn = 241; // Column where the response URL is recorded.
responseSheet.getRange(row, responseColumn).setValue(responseUrl);
}