質問編集履歴

2

response対象を修正

2019/11/20 00:47

投稿

neko_prevent
neko_prevent

スコア4

test CHANGED
File without changes
test CHANGED
@@ -333,3 +333,63 @@
333
333
  }
334
334
 
335
335
  ```
336
+
337
+
338
+
339
+ ### ”●●● = response” の●●●部分を修正したら反映出来ました
340
+
341
+ ```
342
+
343
+ switch (title) {
344
+
345
+ case "被験者ID":
346
+
347
+ date = response;
348
+
349
+ break;
350
+
351
+ case "予約日":
352
+
353
+ name = response;
354
+
355
+ break;
356
+
357
+ case "曜日":
358
+
359
+ language = response;
360
+
361
+ break;
362
+
363
+ case "検査名":
364
+
365
+ kensamei = response;
366
+
367
+ break;
368
+
369
+ case "備考1":
370
+
371
+ bikou1 = response;
372
+
373
+ break;
374
+
375
+ case "備考2":
376
+
377
+ bikou2 = response;
378
+
379
+ break;
380
+
381
+ default:
382
+
383
+ break;
384
+
385
+ }
386
+
387
+ }
388
+
389
+ var bodyPublic = body + "被験者ID:" + date + "\n予約日:" + name + "\n曜日:" + language + "\n検査名:" + kensamei + "\n備考1:" + bikou1 + "\n備考2:" + bikou2 ;
390
+
391
+ sendToSlack(bodyPublic, "#16-会議メンバー共有事項");
392
+
393
+ }
394
+
395
+ ```

1

Webhook URLの後ろのスペースを削除しました

2019/11/20 00:46

投稿

neko_prevent
neko_prevent

スコア4

test CHANGED
File without changes
test CHANGED
@@ -222,4 +222,114 @@
222
222
 
223
223
 
224
224
 
225
+ ### 修正したところ、Googleフォーム送信時に内容が連携されましたが、response内容が誤って反映されます
226
+
227
+ ```
228
+
229
+ function sendToSlack(body, channel) {
230
+
231
+ var url = "https://hooks.slack.com/services/●●●●●";
232
+
233
+ var data = { "channel" : channel, "username" : "ネコちゃん", "text" : body, "icon_emoji" : ":date: " };
234
+
235
+ var payload = JSON.stringify(data);
236
+
237
+ var options = {
238
+
239
+ "method" : "POST",
240
+
241
+ "contentType" : "application/json",
242
+
243
+ "payload" : payload
244
+
245
+ };
246
+
247
+ var response = UrlFetchApp.fetch(url, options);
248
+
249
+ }
250
+
251
+
252
+
253
+ function test() {
254
+
255
+ sendToSlack("テスト通知確認です", "#16-会議メンバー共有事項");
256
+
257
+ }
258
+
259
+
260
+
261
+ function onFormSubmit(e){
262
+
263
+
264
+
265
+ var body = "<! @●●● >心理検査が予約されました!\n";
266
+
267
+ var applicant = "";
268
+
269
+ var itemResponse = e.response.getItemResponses();
270
+
271
+
272
+
273
+ for (var j = 0; j < itemResponse.length; j++){
274
+
275
+ var formData = itemResponse[j];
276
+
277
+ var title = formData.getItem().getTitle();
278
+
279
+ var response = formData.getResponse();
280
+
281
+
282
+
283
+ switch (title) {
284
+
285
+ case "被験者ID":
286
+
287
+ date = response;
288
+
225
- ### 備考
289
+ break;
290
+
291
+ case "予約日":
292
+
293
+ name = response;
294
+
295
+ break;
296
+
297
+ case "曜日":
298
+
299
+ language = response;
300
+
301
+ break;
302
+
303
+ case "検査名":
304
+
305
+ language = response;
306
+
307
+ break;
308
+
309
+ case "備考1":
310
+
311
+ language = response;
312
+
313
+ break;
314
+
315
+ case "備考2":
316
+
317
+ language = response;
318
+
319
+ break;
320
+
321
+ default:
322
+
323
+ break;
324
+
325
+ }
326
+
327
+ }
328
+
329
+ var bodyPublic = body + "被験者ID:" + date + "\n予約日:" + name + "\n曜日:" + language + "\n検査名:" + language + "\n備考1:" + language + "\n備考2:" + language ;
330
+
331
+ sendToSlack(bodyPublic, "#16-会議メンバー共有事項");
332
+
333
+ }
334
+
335
+ ```