2016-06-16 8 views
2

私はこれをどこに投稿すべきかわかりませんでした。私はこれが正しい場所であることを願っています。Googleフォーム> Googleシート> Google Code =メール通知

私はGoogleフォームを持っていますが、回答はフォームが記入されると自動的にGoogleシートに送られます。私は所有者であるため、デフォルトのGoogle通知をセットアップして、Googleフォームが記入されるたびにフォームが変更されたことを通知します:

プロセスは次のとおりです:Googleフォームが埋め込まれています>私のメールアドレスへの通知

私のビジネスの他のユーザーにGoogleシートを共有しました。彼らには、シートに対する編集権限があります。フォームが変更されたときにもこのユーザーに通知を受け取るようにします。

ので、プロセスは次のようになります。それはGoogle Appsのは不可能であるとしてGoogleフォームは私にフォーム>電子メール通知からの応答と私はオンライン検索した

他のユーザーの電子メールアドレスを使用して更新> Googleスプレッドシートに記入まだ(それは所有者に通知するだけです)。私はそれが私と私がしたい他のユーザーのカスタムGoogle Codeの通知メールを送信コードエディタからこのコードを実行すると

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 Codeのメール通知を受け取りません。

私は、トリガーセクションでGoogleコードウェブサイトを見てきましたが、このパートの書き方はわかりません。 シートが変更されたときにカスタムコードを実行すると言うトリガを記述する必要があると思います。

Googleフォームが埋め込まれています>フォームからの応答でGoogleシートが更新されました> Googleシートで変更が発生しました>トリガーでトリガーを設定>トリガーでカスタムGoogleコードを実行>他のユーザー

誰でもトリガーコードの部分を助けることができますか、別のソリューションを推奨することはできますか?

ありがとうございました。

答えて

0

スクリプトエディタの[リソース] - > [現在のプロジェクトのトリガ]メニュー項目でトリガを追加できます。 >「スプレッドシートから」 - - >「変更時に」

+0

ドキュメントの所有者のトリガーを作成できますが、他の人と共有しているにもかかわらず、他の人のトリガーは作成できません。所有者には変更通知メールを送信しますが、他の編集者には送信しないため、扱いにくいです。 –

0

をトリガーするために、私は前に類似したコードを作ったが、

を「MyFunctionを」:次の形式でトリガーを作成

onイベントのイベントです。ここで明確に必要なのは、 "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です。

ここにコメントがあれば、トリガーに役立つことを願っています。

関連する問題