มือใหม่ครับ ตามที่ฝึกฝนมาพบปัญหาว่าชื่อสิ่งเดียวกันจะแสดงได้แค่ 1 ชื่อ ผมเห็นมือเซียน ๆ เขาสามารถทำให้แสดงออกได้ 2 ชื่อ หรือ หลาย ๆ ชื่อ โดยที่ผลการแสดงเลื่อนดูได้ซ้าย - ขวา ผมอยากทราบว่าโค้ชที่ผมหัดเขียนจะต้องเพิ่มตรงไหน อย่างไรครับ
var data = JSON.parse(e.postData.contents)
var userMsg = data.originalDetectIntentRequest.payload.data.message.text;
var values = sheet.getRange(2, 3, sheet.getLastRow(),sheet.getLastColumn()).getValues();
let contents
for(var i = 0;i<values.length; i++){
if(values[0] == userMsg ){
i=i+2;
var Data1 = sheet.getRange(i,2).getValue();
var Data2 = sheet.getRange(i,3).getValue();
var Data3 = sheet.getRange(i,4).getValue();
var Data4 = sheet.getRange(i,5).getValue();
var Data5 = sheet.getRange(i,6).getValue();
var Data6 = sheet.getRange(i,7).getValue();
var Data7 = sheet.getRange(i,8).getValue();
var result = {
"fulfillmentMessages": [
{
"platform": "line",
"type": 4,
"payload" : {
"line": {
"type": "flex",
"altText": "this is a flex message",
"contents":
{
"type": "bubble",
"hero": {
"type": "image",
"url": "xxxxxxxx",
"size": "xxl",
"aspectRatio": "1.51:1",
"aspectMode": "fit"
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": ":: xxxxxxxxxxx ::",
"weight": "bold",
"align": "center",
"color": "#0000ff"
},
{
"type": "text",
"text": Data1+" "+Data2+" "+Data3,
"weight": "bold",
"size": "xl",
"align": "center",
"color": "#ff0000"
},
{
"type": "text",
"text": "xxxxxxx : "+Data4
},
{
"type": "text",
"text": "xxxxxxx : "+Data5
},
{
"type": "text",
"text": "xxxxxx : "+Data6
},
{
"type": "text",
"text": "xxxxxx : "+Data7
}
]
}
}
}
}
}
]
}
var replyJSON = ContentService.createTextOutput(JSON.stringify(result)).setMimeType(ContentService.MimeType.JSON);
return replyJSON;
}
}
}
หัดเขียน google apps script ครับอยากให้แสดงชื่อที่ค้นหาชื่อสิ่งของที่ซ้ำกันได้ มีผลการแสดงแบบเลื่อนซ้าย - ขวา
var data = JSON.parse(e.postData.contents)
var userMsg = data.originalDetectIntentRequest.payload.data.message.text;
var values = sheet.getRange(2, 3, sheet.getLastRow(),sheet.getLastColumn()).getValues();
let contents
for(var i = 0;i<values.length; i++){
if(values[0] == userMsg ){
i=i+2;
var Data1 = sheet.getRange(i,2).getValue();
var Data2 = sheet.getRange(i,3).getValue();
var Data3 = sheet.getRange(i,4).getValue();
var Data4 = sheet.getRange(i,5).getValue();
var Data5 = sheet.getRange(i,6).getValue();
var Data6 = sheet.getRange(i,7).getValue();
var Data7 = sheet.getRange(i,8).getValue();
var result = {
"fulfillmentMessages": [
{
"platform": "line",
"type": 4,
"payload" : {
"line": {
"type": "flex",
"altText": "this is a flex message",
"contents":
{
"type": "bubble",
"hero": {
"type": "image",
"url": "xxxxxxxx",
"size": "xxl",
"aspectRatio": "1.51:1",
"aspectMode": "fit"
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": ":: xxxxxxxxxxx ::",
"weight": "bold",
"align": "center",
"color": "#0000ff"
},
{
"type": "text",
"text": Data1+" "+Data2+" "+Data3,
"weight": "bold",
"size": "xl",
"align": "center",
"color": "#ff0000"
},
{
"type": "text",
"text": "xxxxxxx : "+Data4
},
{
"type": "text",
"text": "xxxxxxx : "+Data5
},
{
"type": "text",
"text": "xxxxxx : "+Data6
},
{
"type": "text",
"text": "xxxxxx : "+Data7
}
]
}
}
}
}
}
]
}
var replyJSON = ContentService.createTextOutput(JSON.stringify(result)).setMimeType(ContentService.MimeType.JSON);
return replyJSON;
}
}
}