Put results of two forms in two sheets of one spreadsheet

我们两清 提交于 2019-12-11 19:32:45

问题


I have a system for accepting and reviewing grant applications. There are two forms:

  1. form submitted by an applicant with a grant request
  2. form sent by me to three reviewers to evaluate a grant request

I'd like to have the results of both forms in one spreadsheet:

Sheet 1 lists the data from the application forms (with an auto-generated serial number).

sheet 2 lists the data from all the reviews for all the applications (with a column for the serial number of the application that was reviewed).

I'm having trouble with:

1 - Specifying that both Forms' results go into the same spreadsheet, on different sheets.

2 - Adding a serial number to the applications and then adding the same serial number to the results of the three reviewers.

Any suggestions?


回答1:


It is impossible to insert data of two Google Forms directly to a single spreadsheet using GAS without involving another two spreadsheets, because now the Forms are able to deploy data only to own spreadsheet and GAS has no any service to access to the Forms.




回答2:


I'm going to be a little general as your asking a rather broad question, but I will do my best. I would consider using UiApp to build forms from the ground up. It will allow you more flexibility in function, and simple a smoother flow of information but since your question is about forms, I will stick to that.

Question 1:You'd want to create an OnSubmit function within each spreadsheet associated with the form 1 and 2 that copy the data you want to another spreadsheet.

function onFormSubmit() { // add an onsubmit trigger 
var emailAddress = e.values[1];
var fullName     = e.values[2];
var newSS = SpreadsheetApp.openById("Add New SS ID").getSheetByName('Sheet1');//one form should be 'Sheet2'
  var range = sheet.getRange(sheet.getLastRow()+1,1,1,2);
range.setValues([[emailAddress, fullName]]);

Question 2: Assign a serial number. To my mind, you only want to assign a number to the applications, and then give that number to the reviewers for them to enter into the form. To assign this number, you can follow the Tutorial: Automating a Help Desk Workflow. Instead, I simply use the get last row, as I never delete rows in an active application so the row numbers are unique.

var serialNum = newSS.getLastRow()+1;

Then you can simply add that variable as you did the rest. I've not tested this code, so you may need to clean it up for your purposes.



来源:https://stackoverflow.com/questions/11435377/put-results-of-two-forms-in-two-sheets-of-one-spreadsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!