2016-06-16 3 views
2

어디에 게시해야하는지 잘 모르겠습니다. 나는 이것이 바른 장소이기를 바란다.Google 양식> Google 시트> Google 코드 = 이메일 알림

Google 양식이 있습니다. 양식이 작성되면 응답이 Google 시트에 자동으로 입력됩니다. 내가 소유자 인 것처럼 Google 양식이 채워질 때마다 양식이 변경되었음을 알리는 기본 Google 알림을 설정했습니다.

프로세스는 다음과 같습니다. Google 양식 입력> 양식의 응답으로 업데이트 된 Google 시트> 이메일 내 이메일 주소로의 알림

내 비즈니스의 다른 사용자에게 Google 시트를 공유했습니다. 회원에게는 시트에 대한 수정 권한이 있습니다. 이 사용자가 양식에 변경 사항이있을 때도 알림을 받길 원합니다.

그래서 과정이 될 것이다 : 그것은 Google 애플리케이션에서 가능하지 않다 구글 양식 광산 양식> 이메일 알림의 응답 내가 온라인 검색 한

다른 사용자의 이메일 주소로 업데이트> 구글 시트에 작성 아직 (소유자에게만 알립니다). 그것은 다음과 같이 내 Google 시트에서 사용자 정의 Google 코드를 만들 것을 권고했다 :

function myFunction() { 
    MailApp.sendEmail("[email protected]","Notification - Change in Spreadsheet","Notification - There has been a change in the Spreadsheet. Please view the change here: (I've put the url of sheet here) "); 

    MailApp.sendEmail("[email protected]","Notification - Change in Spreadsheet","Notification - There has been a change in the Spreadsheet. Please view the change here: (I've put the url of sheet here) "); 
} 

나는 그것이 저와 다른 사용자 내가 원하는 사용자 정의 구글 코드 알림 이메일을 전송하는 코드 편집기에서이 코드를 실행합니다.

양식을 작성하면 답장이 시트에 업데이트되고 공식적인 Google 알림에서 변경 사항에 대한 이메일 알림을받습니다. 다른 사용자와 저는 맞춤 Google 코드 이메일 알림을받지 못했습니다.

트리거 섹션의 Google 코드 웹 사이트를 살펴본 적이 있지만이 부분을 작성하는 방법을 잘 모르겠습니다. 시트가 변경되어 사용자 지정 코드가 실행될 때 나타나는 코드에 트리거를 작성해야한다고 생각합니다.

Google 양식 작성> 양식의 응답으로 Google 시트가 업데이트 됨> Google 시트에서 변경> 시트가 트리거 설정> 트리거는 맞춤 Google 코드> 다른 사용자와 맞춤 Google 코드 이메일 알림을받습니다.

누군가 트리거 코드 부분을 도울 수 있습니까? 아니면 다른 솔루션을 추천 할 수 있습니까?

감사합니다.

답변

0

스크립트 편집기의 "리소스"-> "현재 프로젝트 트리거"메뉴 항목에 트리거를 추가 할 수 있습니다.

다음 형식으로 트리거를 만들 :

"하여 myFunction"-> "스프레드 시트에서"-> 트리거를 들어

+0

문서의 소유자는 트리거를 만들 수 있지만 다른 사람과 공유하더라도 다른 사람이 만들 수는 없습니다. 소유자에게 변경 알림 이메일을 보내지 만 다른 편집자는 보내지 않기 때문에 까다 롭습니다. –

0

"변경에서"나는 유사한 코드 전에 만들었지 만, 한 onChange 이벤트 용입니다. 여기에 분명히 필요한 것은 "OnFormsubmit"트리거입니다. 아래는 인라인 코멘트가있는 사용자 정의 메뉴로 만든 코드입니다.

// Written by Madzihi 
// on a nice Sunday afternoon 

function onOpen(){ //Setting up all the custom menu components 
     var ss = SpreadsheetApp.getActiveSpreadsheet(); //Get the current active Spreadsheet 
     ss.addMenu('Custom Setup',[{name:'Select Sheet', //Assemble all the menu's component 
           functionName:'openSheet'},{name:'Set Trigger',functionName:'triggerSet'}, 
           {name:'Delete Trigger',functionName:'delTrigger'}]); 
     ss.addEditor(Session.getActiveUser().getEmail()); //This line set up so editor(s) don't have to run manually the script to gain authorization 
} 
function triggerSet(){ //Function to setting up the triggers for current project 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); 
    var ui = SpreadsheetApp.getUi(); //Get the UI for setting trigger 
    var triggers = ScriptApp.getProjectTriggers(); //Get the current project's trigger 
    var respond = ui.alert('Setting up new trigger', ui.ButtonSet.OK_CANCEL); //Set the UI prompt message and 'OK/CANCEL' buttons 
     if(respond ==ui.Button.OK && triggers <=1){ //Set the trigger if button 'OK' is clicked and prevent trgger to be installed more than 1 
     ScriptApp.newTrigger('onChanges').forSpreadsheet(ss).onChange().create(); //Line for creating the trigger based on changes that made in google sheet 
     } 
     else if (respond == ui.Button.CANCEL){ //If 'CANCEL' button is clicked will alert user no trigger installed 
     ui.alert('No new trigger have been installed'); 
     } 
     else { ui.alert('No new trigger have been installed') //If close button is clicked will alert user no trigger installed 
     } 
} 
function delTrigger(){ //Setup for deleting trigger 
    var ui= SpreadsheetApp.getUi(); 
     try{ 
     var triggers = ScriptApp.getProjectTriggers(); 
     ScriptApp.deleteTrigger(triggers[0]); //Choosing the trigger to be deleted 
     ui.alert('Your trigger have been deleted'); 
      } 
     catch(e){ 
      ui.alert('No trigger have been set!'); //If there is no trigger have been set, it will throw this alert to user. 
     } 
} 

이 행은 내가 작성한 코드에서 현재 트리거 빌더를 대체해야합니다. 에디터와 사용자 정의 메뉴 중 하나를 클릭하여 인증을 활성화해야합니다.

ScriptApp.newTrigger('onChanges').forForm(key).onFormSubmit().create(); 

이상이 라인에 대한 설명 :

  • 은 'onChange가'
  • '키'를 트리거 한 스프레드 시트 형태의 바인딩의 키/고유 ID입니다 될 함수 이름입니다.

호프 여기에 의견이 있으면 트리거와 함께 도움이되기를 바랍니다.