ออกแบบตาราง จำนวน 3 ตาราง ใน Sheet
Product
Sales
Cart
✅ 1. สร้าง Action: “Checkout Items”
👉 ไปที่ Table: Cart
-
ชื่อ Action:
Mark as Checked Out
-
For a record of this table:
Cart
-
Do this:
Data: set the values of some columns in this row
-
Set Column:
CheckedOut?
→ Value:TRUE
✅ ตอนนี้คือ Action ที่ใช้เปลี่ยนสถานะตะกร้าให้เป็น CheckedOut
สร้าง Action ใหม่ใน Table Sales
-
ไปที่ Behavior > Actions
-
คลิก
+ New Action
-
ตั้งค่าดังนี้:
รายการ | ค่า |
---|---|
Action Name | Mark Sale as Checked Out |
For a record of this table | Sales |
Do this | Set the values of some columns in this row |
Set these columns | |
→ CheckedOut? = TRUE |
✅ ขั้นตอนเพิ่ม Action กลาง (Run action on a set of rows)
🔹 Step A: สร้าง Action ใน Table Sales
-
ไปที่ Behavior > Actions
-
กด New Action
-
ตั้งค่าแบบนี้:
รายการ | ค่า |
---|---|
Name | Run Checkout on Cart |
For a record of this table | Sales |
Do this | Execute an action on a set of rows |
Referenced Table | Cart |
Referenced Rows | ใส่สูตรนี้: |
| Referenced Action | Mark as Checked Out
(จาก Table Cart
) |
สร้าง Grouped Action ในตาราง Sales
✅ ชื่อ: Checkout Sale
-
ไปที่ Behavior > Actions
-
เลือก Table:
Sales
-
กดปุ่ม New Action
-
ตั้งค่า:
-
Name:
Checkout Sale
-
For a record of this table:
Sales
-
Do this:
Group of actions
-
กดปุ่ม
Add
ด้านล่าง
-
เพิ่ม Action แบบ "Execute an action on a set of rows"
-
เลือก:
-
Action:
Execute an action on a set of rows
-
Referenced Table:
Cart
-
Referenced Rows: ใส่สูตรนี้:
Referenced Action:
Mark as Checked Out
✅ ตอนนี้ Action นี้จะเปลี่ยนสถานะของสินค้าทั้งหมดที่ยังไม่ Checkout ในบิลนี้ให้เป็น TRUE
🔹 Step 3: แสดงปุ่ม Checkout Sale บนหน้าจอ
-
ไปที่ UX > Views
-
ไปที่ View ที่ใช้แสดงรายละเอียด Sales เช่น Sales_Detail หรือ Sales_Form
-
เลื่อนลงไปที่ Behavior > Actions
-
ตรง "Event Actions" หรือ "Display prominently" → เลือก Action:
Checkout Sale
-
ตั้ง Icon เช่น 🛒 หรือ ✅ และ Label ว่า "Checkout" ก็ได้
สร้างและอธิบาย ขั้นตอนลูกค้าเลือกสินค้า และส่งไปในตะกร้าสินค้า เพื่อcheckOut
🔄 ขั้นตอนการทำงานของระบบ
💡 แนวคิด:
-
ผู้ใช้เลือกสินค้า (จาก
product
) -
ใส่จำนวน → ระบบคำนวณราคารวม
-
กด “เพิ่มลงตะกร้า” → ข้อมูลจะไปอยู่ใน
cart
-
เมื่อพร้อมแล้ว → กด Checkout เพื่อสร้างใบเสร็จ (บิลขาย) ใน
sales
🧱 ตารางที่ใช้
🔹 product
-
ข้อมูลสินค้า เช่น รหัส, ชื่อ, ราคา, สต็อก
🔹 cart
-
ตะกร้าสินค้า (ข้อมูลสินค้าที่เลือก)
-
มีฟิลด์สำคัญ:
-
CartID
-
SalesID (Ref ไปที่
sales
) -
ProductID (Ref ไปที่
product
) -
Quantity
-
Price (ดึงจาก product)
-
Amount (คำนวณ)
-
CheckedOut? (TRUE/FALSE)
-
🔹 sales
-
ใบบิลขายสินค้า
🛠️ ขั้นตอนการสร้างระบบเลือกสินค้า → ใส่ตะกร้า
🔸 1. สร้าง Action: “Add to Cart”
ไปที่ Table: product
-
Menu: Behavior > Actions
-
สร้าง Action ใหม่
Field | Value |
---|---|
Action name | AddToCart |
For a record of this table | product |
Do this | Data: add a new row to another table using values from this row |
Target table | cart |
Set these columns | ตามนี้ด้านล่าง |
LINKTOFORM()
แบบเปิดฟอร์มแทรกจำนวน🔸 2. สร้างฟอร์มสำหรับเพิ่มรายการในตะกร้า
ใน Table: cart
-
ไปที่ UX > Views
-
สร้าง View แบบ
Form
-
Table:
cart
-
ตั้งชื่อว่า:
cart_Form
-
Show if:
FALSE
(ซ่อนไว้ เพราะเรียกผ่าน Action)
🔸 3. เพิ่ม Action ปุ่ม "Add to Cart" บนหน้าสินค้า
-
ใน Table
product
ให้แสดง Action “AddToCart” -
ใน UX > View → Table View หรือ Deck View ของ
product
-
Section: “Actions” → ใส่ Action “AddToCart” เป็นปุ่มด้านขวา
🔸 4. เมื่อกดปุ่ม → ฟอร์มเพิ่มรายการเปิดขึ้น
ผู้ใช้จะใส่จำนวนสินค้า แล้วกด “Save”
→ รายการจะถูกเก็บใน cart
ทันที
🔸 5. สร้าง View แสดงตะกร้าสินค้า (Cart View)
-
Table:
cart
-
Slice: แสดงเฉพาะที่ยัง
CheckedOut? = FALSE
-
UX > View type: Table / Deck
-
ตั้งชื่อว่า:
My Cart
Optional:
-
Grouped by: SalesID
-
Columns: ProductName, Quantity, Amount
🔸 6. สร้างปุ่ม Checkout Sale
ให้ดูรายละเอียดที่เราทำไว้ก่อนหน้า:
-
Action กลุ่ม: Mark as Checked Out, Update Sales Amount
-
หรือใช้ Bot ก็ได้
✅ สรุป Flow การใช้งาน
ขั้นตอน | รายละเอียด |
---|---|
1. ผู้ใช้เปิดหน้า "Product" | เลือกสินค้า กดปุ่ม "Add to Cart" |
2. ฟอร์มเปิดให้ใส่จำนวน | บันทึกแล้วส่งข้อมูลไป cart |
3. ตะกร้าเก็บข้อมูลสินค้า | เชื่อมกับ salesID เดียวกัน |
4. ผู้ใช้เปิด “My Cart” | ดูสินค้าที่จะซื้อ |
5. กดปุ่ม “Checkout Sale” | สรุปรายการ → อัปเดตสถานะและยอดขาย |
cart
คอลัมน์
ประเภท
การตั้งค่าเพิ่มเติม
CartID
Text (Key)
เช่น [SalesID] & "-" & [ProductID]
SalesID
Ref → sales[SalesID]
❌ ไม่เปิด Is a part of?
ProductID
Ref → product[ProductID]
Quantity
Number
Price
Number
App formula
: [ProductID].[Price]
Amount
Number
App formula
: [Quantity] * [Price]
CheckedOut?
Yes/No
Default = FALSE
ขั้นตอนแบบละเอียด สำหรับการสร้าง ระบบเพิ่มสินค้าเข้าตะกร้า (Cart) ด้วย Action
, LINKTOFORM
, และ UX Form
แบบอัตโนมัติ เพื่อใช้ในระบบขายสินค้าผ่าน AppSheet ✅
Table Name
ใช้สำหรับ
product
แสดงรายการสินค้า
sales
เก็บข้อมูลบิล
cart
เก็บสินค้าในแต่ละบิล (SalesID)
✅ 1. เตรียมฟอร์ม Cart
ใน ตาราง cart
ให้สร้างฟอร์มแบบ UX ดังนี้
📍ไปที่เมนู UX
> Views
:
-
View name: Cart_Form
-
For this data: cart
-
View type: form
-
Position: off (หรืออื่นๆ แล้วแต่ความเหมาะสม)
-
Behavior:
-
Auto save: ✅ On (ถ้าต้องการให้บันทึกทันทีเมื่อเลือกสินค้า)
✅ 2. สร้าง Action บนตาราง product
เพื่อเพิ่มสินค้าเข้า Cart
📍ไปที่ Behavior
> Actions
> กด “+ New Action”
ค่า
รายละเอียด
For a record of this table:
product
Action name:
Add to Cart
Do this:
App: go to another view within this app
Target:
ใช้สูตร LINKTOFORM()
ด้านล่าง 👇
LINKTOFORM( "Cart_Form", "SalesID", ANY(SELECT(sales[SalesID], [CheckedOut?] = FALSE)), "ProductID", [ProductID], "Quantity", 1)✅ 3. แสดงปุ่ม "Add to Cart" บนตารางสินค้า
📍กลับมาที่ UX > Views:
-
View name: Product_List
-
For this data: product
-
View type: deck
หรือ table
จากนั้น:
-
เปิด "Actions" ด้านล่าง
-
Show overlay action: ✅ เลือก Add to Cart
(ที่สร้างในขั้นตอน 2)
✅ 4. ตรวจสอบผลลัพธ์
ลองเปิดแอป แล้วดูที่หน้ารายการสินค้า (product)
คุณจะเห็นปุ่ม "Add to Cart" → เมื่อกดจะเปิด Cart_Form
พร้อมข้อมูล:
-
SalesID (ที่ยังไม่ปิดบิล)
-
ProductID (สินค้าที่กด)
-
Quantity = 1
เมื่อกด Save → บันทึกเข้า cart
ทันที ✅