2017-05-14 1 views
0

스프레드 시트의 일부 정보를 업데이트하기 위해 Google 양식 제출에서 사용자 스프레드 시트 기능을 호출하고 싶습니다.Google 양식 스크립트에서 스프레드 시트 기능 실행

모든 스크립트는 동일한 Google 드라이브에 있습니다.

할 방법이 있습니까? 내 Google 형태로

코드 :

function updateSheet() { 
    spreadsheet = SpreadsheetApp.openById('daedaeddea'); 
    spreadsheet.myFunction(); 
} 

function onOpen() { 
var form = FormApp.openById('deadeadaedae'); 
ScriptApp.newTrigger('updateSheet') 
    .forForm(form) 
    .onFormSubmit() 
    .create(); 
} 
+1

스프레드 시트가 스크립트를 실행하는 데 사용할 수있는'onFormSubmit' 트리거가 있습니다. 양식이 아닌 스프레드 시트에서 호출하십시오. – Brian

+0

내 경우에는 첨부 된 양식이있는 스프레드 시트가 아닙니다. 스프레드 시트는 양식과 독립적입니다. – eleandar

+0

"사용자 스프레드 시트 기능"이란 무엇입니까? –

답변

0

당신은 확실히 스프레드 시트와 구글 양식을 연결할 수 있습니다. onFormSubmit 트리거를 사용하여이 작업을 수행하는 방법에 대한 샘플은 Quickstart: Managing Responses for Google Forms입니다.

여기에 코드 조각입니다 : 첨부 된 형태의

function onFormSubmit(e) { 
    var user = {name: e.namedValues['Name'][0], email: e.namedValues['Email'][0]}; 

    // Grab the session data again so that we can match it to the user's choices. 
    var response = []; 
    var values = SpreadsheetApp.getActive().getSheetByName('Conference Setup') 
    .getDataRange().getValues(); 
    for (var i = 1; i < values.length; i++) { 
    var session = values[i]; 
    var title = session[0]; 
    var day = session[1].toLocaleDateString(); 
    var time = session[2].toLocaleTimeString(); 
    var timeslot = time + ' ' + day; 

    // For every selection in the response, find the matching timeslot and title 
    // in the spreadsheet and add the session data to the response array. 
    if (e.namedValues[timeslot] && e.namedValues[timeslot] == title) { 
     response.push(session); 
    } 
    } 
    sendInvites_(user, response); 
    sendDoc_(user, response); 
} 
+0

Google 스프레드 시트 스크립트를 Google 양식 스크립트에서 호출 할 수없는 것으로 보입니다. Google 양식 스크립트에서 스프레드 시트를 조작하는 코드를 다시 작성해야합니다. – eleandar

관련 문제