Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Question - Answer from Web Applications [Show URL used to edit responses from a Google Form in a Google Spreadsheet by using a script](

Revision 3

Show URL used to edit responses from a Google Form in a Google Spreadsheet by using a script

I'm trying to make the edit URL for a Google Form automatically populate in the response Google Sheet that it's attached to. I've seen this already and want to use it, but I'm having issues trying to figure out where exactly to put the script.

I've tried putting it in the script editor in the Google Spreadsheet that I would like the URL to appear in, but I'm not sure where to go from there. In the script editor I've tried to test it as an add-on but that didn't end up working.

I have little experience with scripts and the script editor in Google Sheets. As a final note I am using one other add-on called AutoCrat in the same Google Spreadsheet.

Revision 5

#Short answer The link points to a Q&A that has two answers but non-of them looks to me to be appropiate. I.E. the code of one of answers is incomplete and both of them send emails, so the adoption is too complex to be used as a starting point.

Below is a script that is easier to adopt.


  1. Create a test form and note the form ID (between ../d/ and /edit in the url). New form

  2. Set the form to send responses to a new spreadsheet. Connect a spreadsheet

  3. You'll be redirected to the new spreadsheet. Note the active sheet name (rename it if you want) and add a header to the column to be used to hold the response edit URLs, i.e. Edit Url. NOTE: Capitalization is very important, so be very careful on how do you write it. Responses spreadsheet

  4. Go to Tools > Script editor to add a Google Apps Script project bounded to the spreadsheet. Spreadsheet scripts

  5. Replace the default code with the code below (remember to edit the global variables according to your case). Script code

  6. Save the project, and then add an installable form summit trigger (if you get an "Authorization required" dialog, click "Review Permissions" and then "Allow"). Form submit trigger

  7. Submit some sample responses to test the solution.


 * Global Variables

// Form URL
var formURL = '';
// 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);
Copy link

mustavanov commented Jan 9, 2021

@WhiteRabbitObject I faced the same problem as yours , I solved it by using the sharing URL of the form , in the form click SEND and then change permission to everyone with the link and copy that link and paste it instead of the URL given in the script, that's all and it will work

Copy link

karahk commented Jun 15, 2021

This script works well however I am wondering if there was a way to hide the "Edit your response" link after form submission as I would only like to provide the Edit Url link for certain responses. The Edit Url link would be provided in a separate email.

Copy link

arvr50 commented Aug 25, 2021

I writing the code this way -


For testing purpose, when I submitted a new form the response url got generated but it keeps giving me this error -


Any workaround for this?

Copy link

Baptenda commented Aug 20, 2022

I tried the troubleshooting steps above, but the only solution that worked for me was to open the Google Form and go to the menu (3 vertical dots on the right), then add collaborators. I then clicked "Copy editor link". This link grabbed here was pasted and it worked perfectly.

Copy link

BeHoSam commented Sep 17, 2022

Hello there !
Is there a way to edit row that was not inserted by Google Form ?

Copy link

Baptenda commented Sep 17, 2022


I am not sure I get you well. If the content is in the spreadsheet linked to the Google Forms, then yes, just delete the content. Is there any error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment