![見出し画像](https://assets.st-note.com/production/uploads/images/150643304/rectangle_large_type_2_67555d048755c3f426380cb66581a4ec.jpeg?width=1200)
【AppSheet】シンプルなメモ帳アプリを作る(Part3)Call a scriptでGASを実行するAutomationを設定する
AppSheetのAutomation機能を使って、Google Apps Script(GAS)を呼び出す方法を検証します。GASを使うことで、Google Workspaceアプリケーションとの連携やカスタムロジックの実行が可能になります。
目次
GASプロジェクトの作成
まず、GASプロジェクトを作成します。以下の手順で進めてください。
Google Apps Scriptにアクセスします。
「+ 新しいプロジェクト」をクリックします。
プロジェクト名を「helloLogger」などに変更します。
![](https://assets.st-note.com/img/1723591141868-axoRlc3hmD.jpg?width=1200)
下のようなコードをエディタに貼り付けます
function helloLogger() {
Logger.log("Hello, Logger!");
}
![](https://assets.st-note.com/img/1723591150730-bcaG7wf14P.jpg?width=1200)
「プロジェクトを保存」をクリックします。
GASを呼び出すAutomationを設定
アプリエディタで、左側メニューの「Automation」をクリックします。
「+ New Bot」をクリックし、新しいボットを作成します。
![](https://assets.st-note.com/img/1723591164051-IFYyktj6Rl.jpg?width=1200)
When this EVENT occurs
![](https://assets.st-note.com/img/1723591175509-VJ0QMZgA6H.jpg?width=1200)
exelogといったEVENT occursのnameを設定します。
![](https://assets.st-note.com/img/1723591184900-lAze0b9ROG.jpg?width=1200)
Run this PROCESS:(Call a script)
Run this PROCESS:をCall a scriptに設定します。
![](https://assets.st-note.com/img/1723591194279-fK4OW8pql6.jpg?width=1200)
Function Nameには、スクリプト内の関数を設定します。
![](https://assets.st-note.com/img/1723591204264-jQc9piAb9G.jpg?width=1200)
Actionsの作成
実行したいアクションを作成します。
AppSheetエディタで、左側メニューの「Actions」をクリックします。
「+Add a new action」をクリックします。
![](https://assets.st-note.com/img/1723591217019-sppYg3XoJH.jpg?width=1200)
アクションの設定を行います。
「For a record of this table」:アクションを実行するテーブルを選択します。
「Do this」:アクションの種類を選択します(例:「Data: set the values of some columns in this row」)。
![](https://assets.st-note.com/img/1723591227377-iRKiz0Opwp.jpg?width=1200)
「Set these columns」:変更する列とその値を設定します。
例えば、Set these columnsに[トリガー] + 1とすることで、値に1を加算できます。
![](https://assets.st-note.com/img/1723591236439-F2fhtC0uov.jpg?width=1200)
アクションに名前を付け、保存します。ボタンを押すと、Actionsが実行されます。
![](https://assets.st-note.com/img/1723591248671-sRs5a4UIpu.jpg?width=1200)
値が1増えました。
![](https://assets.st-note.com/img/1723591260568-bQEVzfGi1x.jpg?width=1200)
いいなと思ったら応援しよう!
![eguweb](https://assets.st-note.com/production/uploads/images/128772862/profile_0d1f4028e5611b5742ea863753e41113.png?width=600&crop=1:1,smart)