回答編集履歴

1

あんだーすこあ

2022/12/14 22:59

投稿

Cocode
Cocode

スコア2314

test CHANGED
@@ -3,7 +3,7 @@
3
3
  検証していないので正常に動作するか分かりませんが、こんな感じはどうでしょう?
4
4
 
5
5
  ```javascript
6
- function getValue() {
6
+ function getValue_() {
7
7
  const ss = SpreadsheetApp.getActiveSpreadsheet();
8
8
  const sheet = ss.getSheetByName('抽出');
9
9
 
@@ -14,10 +14,15 @@
14
14
  }
15
15
 
16
16
  function myFunction() {
17
- const val = getValue(); // F2の値を取得
17
+ const val = getValue_(); // F2の値を取得
18
18
  const query = `subject:"お問い合わせ",after:${val}`; // F2の値をafterにいれる
19
+
19
20
  const gmail = getGmail(query);
20
21
  const sheet = SpreadsheetApp.getActive().getActiveSheet();
21
22
  gmail.forEach(info => sheet.appendRow(info));
22
23
  }
23
24
  ```
25
+
26
+ ちなみに、`getValue_()`のように関数名の末尾にアンダースコア(`_`)を記入すると、GASのスクリプトエディタの[実行▷]の関数一覧から除外されます。
27
+ 外部から呼び出す必要のない関数はアンダースコアをつけておくと良いです。
28
+ 一覧から無駄な関数が減ってスッキリもしますしね。