0

스프레드 시트 값에서 트리거와 함께 Google 양식을 보낼 수 있습니까? 그렇다면 어디에 도움을 청합니까?스프레드 시트 값에서 트리거와 함께 Google 양식을 보낼 수 있습니까?

나는

http://www.leadersoftomorrowisn.org/Become_a_Member.html 내가 질문 5 응답을 할 수 있도록하려면 여기에서 볼 수있는 구글 양식을 만들어 본 적이 "당신은에 관심이 무엇을?" 특정 Google 양식을 발송하는 데 사용하십시오.

스프레드 시트 값에서 트리거와 함께 Google 양식을 보낼 수 있습니까? 그렇다면 어디에서 도움을 얻을 수 있습니까?

최저

, 맥스웰

답변

1

는 이제 가정하자 귀하의 가입 회원 형태가 응답을 수신하고, 당신은 그들이 와서 응답을 검토하는 Form Response 트리거 스크립트를 만들 것이라고 스프레드 시트를 가지고있다. 그 방아쇠를 onFormSubmit()이라고 부를 것입니다. 양식 스크립트 또는 스프레드 시트 스크립트 내에 포함 된이 트리거 함수를 작성하는 옵션이 있습니다. 해당 컨테이너 중 하나가 양식 응답을 수신 할 수 있습니다. 이 선택은 어느 이벤트가 onFormSubmit()에 의해 수신되는지를 지시합니다 - 자세한 내용은 Understanding Events을 참조하십시오.

관심 분야에 따라 추가 Google 양식 세트를 만들거나 이미 가지고 있습니다. 이러한 각 양식에는 고유 한 ID가 있으며 이는 응답자에게 보낼 양식의 URL을 얻는 데 사용됩니다. API에 대한 자세한 내용은 Class FormApp을 참조하십시오. 각 관심 양식에 대해 고유 한 ID를 스크립트에 삽입해야합니다.이 ID는 사용자가 양식 편집기 또는 라이브 양식에있는 동안 URL에 나타납니다.

onFormSubmit에서 양식 제출 이벤트를 사용하여 현재 응답 사본을 읽을 수 있습니다. 질문 5는 checkBox 질문이므로 확인 된 모든 답은 쉼표로 구분 된 문자열로 전달됩니다. 질문에 쉼표를 사용하지 않도록 조심하십시오! 아래 예에서 질문 5에 대한 응답으로 관심 분야 배열을 얻은 다음 split에 대한 추가 설문 조사에 전자 메일 링크를 보내고 있습니다. 그것은 매우 조잡하고 당신의 폼과 매우 밀접하게 결합되어 있지만 트릭을해야합니다.

function onFormSubmit(event) { 
    // Get the responses into convenient variables. 
    var firstName = event.values[1];  // Question 1 
    var lastName = event.values[2];  // Question 2 
    var email = event.values[3];   // Question 3 
    var allInterests = event.values[5] // Question 5, a comma-separated list, 
          .split(','); // which we turn into an array 

    // Loop over all expressed interests, sending surveys 
    for (var interest in allInterests) { 
    sendInterestSurvey(firstName, lastName, email, allInterests[interest]); 
    } 
} 

/** 
* Determine the id for a form that matches the given survey (interest), 
* and send an email to the respondent. 
*/ 
function sendInterestSurvey(firstName, lastName, email, survey) { 
    var surveyFormId = null; // Will fill with appropriate survey ID 

    // Set serveyFormId according to current value of 'survey'. 
    switch (survey) { 
    case "Becoming an LOT Member of the USD Chapter": 
     surveyFormId = '1234567890abcdefghijklmnopqrstuvwxyz'; // Replace with real form ID 
     break; 
    case "Presenting a business idea at one of USD's Business Opportunity Meetings (Spring 2014)": 
     surveyFormId = '1234567890abcdefghijklmnopqrstuvwxyz'; // Replace with real form ID 
     break; 
    // and so on... 
    default: 
     // Error handling, or for "other" 
     break; 
    } 

    // Send an email for any interest with a survey form 
    if (surveyFormId != null) { 

    var existingForm = FormApp.openById(surveyFormId); 
    var surveyURL = existingForm.getPublishedUrl(); 
    var surveyTitle = existingForm.getTitle(); 

    // Build Email Body 
    var body = 'Dear '+firstName+' '+lastName+',<br><br>'; // Dear John Doe, 
    body += 'Thanks for completing our Member Contact Information.<br><br>'; 
    body += 'You expressed an interest in: ' + survey; 
    body += ', and we would like to get more details about your interest.<br><br>'; 
    body += 'Please follow <a href="' +surveyURL+ '">this link</a> to complete the survey.<br><br>'; 
    body += 'Thank you!'; 

    MailApp.sendEmail({ 
    to: email, 
    subject: surveyTitle, 
    htmlBody: body 
    }); 
    } 
} 

당신은 예를 들어 당신은 이미 채워 응답자의 이름으로 추가 조사의 프리 필드 버전에 대한 URL을 생성 할 수있는, 더이 걸릴 수 있습니다.