I have connected my Google form to my spreadsheet. I have a blank (column 1) that I would like to be filled with the edit url that will take me back to the form so that I can edit the response from the form.
I used to use a code similar to this. But I can't get this one to work. It runs without error but does nothing. Column 1 Does have matching Header "Edit Url"
// Form URL
var formURL = 'https://docs.google.com/forms/d/form-id/viewform';
// Sheet name used as destination of the form responses
var sheetName = 'Form Responses 1';
/*
* Name of the column to be used to hold the response edit URLs
* It should match exactly the header of the related column,
* otherwise it will do nothing.
*/
var columnName = 'Edit Url' ;
// Responses starting row
var startRow = 2;
function getEditResponseUrls(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
var columnIndex = headers[0].indexOf(columnName);
var data = sheet.getDataRange().getValues();
var form = FormApp.openByUrl(formURL);
for(var i = startRow-1; i < data.length; i++) {
if(data[i][0] != '' && data[i][columnIndex] == '') {
var timestamp = data[i][0];
var formSubmitted = form.getResponses(timestamp);
if(formSubmitted.length < 1) continue;
var editResponseUrl = formSubmitted[0].getEditResponseUrl();
sheet.getRange(i+1, columnIndex+1).setValue(editResponseUrl);
}
}
}
What am I missing" The form is setup to allow responses to be edited immediately after user hits submit
I tried adjusting the above code so that sheet name and form url were correct. I haven't had success in the past with fanatical, solution. I just need to run the simpler app script coding.
Problem Solved... here is the fix Edit Url column needed to be the last column The Form Link ... needed to be the "/edit" url and not the "/viewform" Link