Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I map specific parts of a Google Form to one spreadsheet, and other parts to another spreadsheet? Some of the responses on one will be public and viewable by anyone, but others will be private.

share|improve this question

You can run a script that will catch the submitted responses, then add a row to the public spreadsheet with the appropriate data. If you need any help writing this, let me know.

Edit

Something like this should do it:

/**
 * This will 
 * set a trigger for this as described here: 
 * https://developers.google.com/apps-script/understanding_triggers#ActionTriggers
 * @param {Object} e The event parameter for form submission to a spreadsheet;
 *     see https://developers.google.com/apps-script/understanding_events
 */

function onSubmit(e){
  properties = {publicSheetId:'PUT YOUR PUBLIC SHEET HERE',
                publicFields:['Question 1', 'Question 2?']};
  var form = FormApp.getActiveForm();
  var responses = form.getResponses();
  Logger.log(responses);
  var lastResponse = responses[responses.length -1];
  var publicSheet = SpreadsheetApp.openById(properties.publicSheetId);
  //form = FormApp.getActiveForm();
  //e = FormApp.getActiveForm().getResponse()
  Logger.log(lastResponse.getId());
  var itemResponses = lastResponse.getItemResponses()
  var publicItemResponses = []
  for (var i = 0; i < properties.publicFields.length; i++){
    var publicField = properties.publicFields[i]
    for (var j = 0; j < itemResponses.length; j++) {
      var itemResponse = itemResponses[j];
      Logger.log(itemResponse.getItem().getTitle());
      Logger.log(publicField);
      if(itemResponse.getItem().getTitle() == publicField){
        publicItemResponses.push(itemResponse.getResponse());
        break;
      }
    }
  }
  publicSheet.getSheets()[0].appendRow(publicItemResponses);
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.