Skip to content

Instantly share code, notes, and snippets.

  • Select an option

  • Save latestalexey/5a5ad2bfca587e68e714987420aaeb74 to your computer and use it in GitHub Desktop.

Select an option

Save latestalexey/5a5ad2bfca587e68e714987420aaeb74 to your computer and use it in GitHub Desktop.

Revisions

  1. @pierandrea pierandrea revised this gist Mar 19, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion How to use it
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    Copy the code above.
    Passte it in the Google Sheet where you want to collect the edit response links.
    Paste it in the Google Sheet where you want to collect the edit response links.
    Change the following parameters:
    line 2 - Google Form ID number;
    line 5 - Destination Worksheet name;
  2. @pierandrea pierandrea renamed this gist Mar 19, 2015. 1 changed file with 0 additions and 0 deletions.
  3. @pierandrea pierandrea revised this gist Mar 19, 2015. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
  4. @pierandrea pierandrea renamed this gist Mar 19, 2015. 1 changed file with 0 additions and 0 deletions.
  5. @pierandrea pierandrea renamed this gist Mar 19, 2015. 1 changed file with 0 additions and 0 deletions.
  6. @pierandrea pierandrea renamed this gist Mar 19, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. @pierandrea pierandrea renamed this gist Mar 19, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. @pierandrea pierandrea revised this gist Mar 19, 2015. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions How to use it
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    Copy the code above.
    Passte it in the Google Sheet where you want to collect the edit response links.
    Change the following parameters:
    line 2 - Google Form ID number;
    line 5 - Destination Worksheet name;
    line 9 - Column number where edit response links should be collected;
    Save and run script.
    Check that edit response links are collected in the right column in your destination Sheet
  9. @pierandrea pierandrea created this gist Mar 19, 2015.
    22 changes: 22 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    function assignEditUrls() {
    var form = FormApp.openById('yourFormKey');
    //enter form ID here

    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('yourWorksheetName');

    //Change the sheet name as appropriate
    var data = sheet.getDataRange().getValues();
    var urlCol = ; // column number where URL's should be populated; A = 1, B = 2 etc
    var responses = form.getResponses();
    var timestamps = [], urls = [], resultUrls = [];

    for (var i = 0; i < responses.length; i++) {
    timestamps.push(responses[i].getTimestamp().setMilliseconds(0));
    urls.push(responses[i].getEditResponseUrl());
    }
    for (var j = 1; j < data.length; j++) {

    resultUrls.push([data[j][0]?urls[timestamps.indexOf(data[j][0].setMilliseconds(0))]:'']);
    }
    sheet.getRange(2, urlCol, resultUrls.length).setValues(resultUrls);
    }