回答編集履歴
1
あ
test
CHANGED
@@ -1,25 +1,63 @@
|
|
1
1
|
```javascript
|
2
2
|
|
3
|
-
i
|
3
|
+
// 実行メニューから「Chorme V8 を搭載した新しい Apps Script ランタイムを有効にする」を選択してください
|
4
4
|
|
5
|
-
|
5
|
+
/*
|
6
6
|
|
7
|
-
|
7
|
+
スプレッドシートのK列(入居予定日)が入力されたら
|
8
8
|
|
9
|
-
|
9
|
+
同じ行のA列(物件名)、B列(部屋番号)、K列(入居予定日)をチャットワークに送信したいです。
|
10
10
|
|
11
|
-
|
11
|
+
*/
|
12
|
+
|
13
|
+
const q242949_onEdit = (e) => {
|
14
|
+
|
15
|
+
const token = ""; // token of ChatWork
|
16
|
+
|
17
|
+
const sheetName = "ぶっけんちょうせいシート(最新)(コピー)_new"; //本当のシート名にしてください。
|
18
|
+
|
19
|
+
const watchColumn = "K"; // 動作のきっかけになるのは K 列
|
12
20
|
|
13
21
|
|
14
22
|
|
15
|
-
|
23
|
+
if(!e.value) return;
|
16
24
|
|
17
|
-
|
25
|
+
const curRange = e.range;
|
18
26
|
|
19
|
-
|
27
|
+
const c = curRange().getColumn();
|
20
28
|
|
29
|
+
if(!getColNumbersA1(watchColumn).includes(c)) return;
|
30
|
+
|
31
|
+
const r = curRange.getRow();
|
32
|
+
|
33
|
+
if(r === 1) return;
|
34
|
+
|
35
|
+
const sheet = curRange.getSheet();
|
36
|
+
|
37
|
+
if(sheet.getName() !== sheetName) return;
|
38
|
+
|
39
|
+
const [building,room] = sheet.getRange(r,1,1,2).getValues()[0]
|
40
|
+
|
41
|
+
const message = `物件名:${building}
|
42
|
+
|
43
|
+
部屋番号:${room}
|
44
|
+
|
45
|
+
入居予定日:${e.value}`;
|
46
|
+
|
47
|
+
sendMessage(token, message);
|
48
|
+
|
21
|
-
|
49
|
+
}
|
50
|
+
|
51
|
+
const sendMessage = (token,data) => {
|
52
|
+
|
53
|
+
const cw = ChatWorkClient.factory({token:token});
|
54
|
+
|
55
|
+
cw.sendMessageToMyChat(data);
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
const getColNumbersA1 = str => str.split("").map(getColNumberA1);
|
60
|
+
|
61
|
+
const getColNumberA1 = alpha => "_ABCDEFGHIJKLMNOPQLSTUVWXYZ".indexOf(alpha.toUpperCase());
|
22
62
|
|
23
63
|
```
|
24
|
-
|
25
|
-
だと思います。
|