SharePoint.Contents ดึงรายการโฟลเดอร์และไฟล์ทั้งหมดจาก SharePoint site เป็น navigation table ที่สามารถ drill down ไปยัง Document Libraries และ Lists ต่างๆ ได้
=SharePoint.Contents(url as text, optional options as nullable record) as table
=SharePoint.Contents(url as text, optional options as nullable record) as table
| Argument | Type | Required | Default | Description |
|---|---|---|---|---|
| url | text | Yes | URL ของ SharePoint site เช่น https://company.sharepoint.com/sites/TeamSite (ต้องเป็น site URL ไม่ใช่ folder URL) | |
| options | nullable record | Optional | null | Record สำหรับกำหนด options เช่น ApiVersion (14, 15 หรือ “Auto”) และ Implementation (2.0 หรือ null) |
let Source = SharePoint.Contents("https://company.sharepoint.com/sites/TeamSite") in Sourcelet
Source = SharePoint.Contents("https://company.sharepoint.com/sites/TeamSite")
in
Source
Navigation table ที่มี Document Libraries และ Lists ต่างๆ ของ site
let Source = SharePoint.Contents( "https://company.sharepoint.com/sites/ThaiTeam", [ApiVersion = 15] ) in Sourcelet
Source = SharePoint.Contents(
"https://company.sharepoint.com/sites/ThaiTeam",
[ApiVersion = 15]
)
in
Source
Navigation table ดึงมาโดยใช้ API version 15 ซึ่งรองรับภาษาไม่ใช่อังกฤษ
let Source = SharePoint.Contents( "https://company.sharepoint.com/sites/Sales", [ApiVersion = "Auto"] ) in Sourcelet
Source = SharePoint.Contents(
"https://company.sharepoint.com/sites/Sales",
[ApiVersion = "Auto"]
)
in
Source
Navigation table โดยระบบจะตรวจสอบ version ของ SharePoint เอง
let Source = SharePoint.Contents( "https://company.sharepoint.com/sites/HR", [ApiVersion = 15, Implementation = 2.0] ) in Sourcelet
Source = SharePoint.Contents(
"https://company.sharepoint.com/sites/HR",
[ApiVersion = 15, Implementation = 2.0]
)
in
Source
Navigation table โดยใช้ connector version 2.0 ที่มี API ปรับปรุง
SharePoint.Contents ดึง navigation table ของทั้ง site ต้อง drill down ไปหา Document Library แต่ละชั้น ส่วน SharePoint.Files ดึงเฉพาะไฟล์จาก Document Library ที่ระบุโดยตรง ถ้าต้องการดึงไฟล์โดยตรงใช้ SharePoint.Files จะตรงประเด็นกว่า
ถ้า SharePoint site ใช้ภาษาอังกฤษ version 14 ก็พอ แต่ถ้าใช้ภาษาอื่นต้องใช้ 15 ขึ้นไป ผมแนะนำใส่ [ApiVersion = 15] เสมอเพื่อความปลอดภัย
Error นี้เกิดจากไม่มีสิทธิ์เข้าถึง SharePoint site ให้ไปที่ Data Source Settings แล้ว Clear Permissions แล้ว sign in ใหม่ หรือติดต่อ admin เพื่อขอสิทธิ์
SharePoint.Contents เป็นฟังก์ชันสำหรับเชื่อมต่อกับ SharePoint site และดึงเนื้อหาทั้งหมดออกมาเป็น navigation table
ที่เจ๋งคือผลลัพธ์จะเป็นตารางแบบ hierarchical ซึ่งมี Content column เป็น link ที่สามารถคลิกเข้าไปยังเนื้อหาหนึ่งชั้นลึกได้ ทำให้เราสามารถสำรวจโครงสร้าง site ได้อย่างสะดวก
ส่วนตัวผมใช้ฟังก์ชันนี้เวลาต้องการดูภาพรวมของ site ว่ามี Document Library อะไรบ้าง แล้วค่อย drill down เข้าไปที่ library ที่ต้องการ ถ้าต้องการดึงไฟล์จาก folder เฉพาะโดยตรง ก็ใช้ SharePoint.Files ที่จะให้ flat list ไม่ต้องคลิก expand มากมาย 😊