Skip to Content
🚀 Welcome to Humansoft Open API Documentation

Get Holiday Change Custom Fields

ดึงข้อมูลคอนฟิกและค่าที่บันทึกไว้ของ Custom Field สำหรับเอกสารการเปลี่ยนวันหยุด

ใช้ API นี้เพื่อดึงฟิลด์เพิ่มเติม (Custom Field) ที่ตั้งค่าไว้สำหรับเอกสารการเปลี่ยนวันหยุด คืนค่าทั้งโครงสร้างฟิลด์ (config), ตัวเลือก (options), เงื่อนไขการตรวจสอบ (validation_json) และค่าที่บันทึกไว้ในเอกสาร (value)

Endpoint

GET /api/v1/open-apis/holiday-change/get-custom-fields

สิทธิ์ที่ต้องการ: API Key ต้องมีสิทธิ์ ข้อมูลการยื่นเอกสาร (document:manage)

Request Parameters

Required Parameters

ParameterTypeRequiredDescriptionExample
holiday_change_idstringYesID เอกสารการเปลี่ยนวันหยุด (Base64)MjAyNjA0MzBIQzAwMDAwMDAx

Response Format

Success Response (HTTP 200)

{ "code": "200", "message": "Get Data Custom Field Holiday Change Success", "payload": [ { "custom_field_config_id": "20240101CF0002", "custom_field_module": "document", "custom_field_system_id": null, "custom_field_code": "CF0002", "custom_field_label": "เหตุผลการเปลี่ยนวันหยุด", "custom_field_label_en": "Reason for holiday change", "custom_field_type": "text", "default_value": null, "placeholder": "ระบุเหตุผล", "placeholder_en": "Enter reason", "is_required": "N", "is_employee_edit_flag": "Y", "validation_json": { "format": "text", "pattern": "^[a-zA-Zก-๙\\s]+$", "message_th": "กรอกได้เฉพาะตัวอักษร", "message_en": "Only letters are allowed" }, "order_no": 1, "last_upd": "2026-02-18 09:12:33", "publish_flag": "Y", "options": [], "value": "สลับวันหยุดประจำสัปดาห์" }, { "custom_field_config_id": "20240101CF0005", "custom_field_module": "document", "custom_field_system_id": "20240101CS0000000001", "custom_field_code": "CF0005", "custom_field_label": "หน่วยงานที่รับผิดชอบ", "custom_field_label_en": "Responsible Cost Center", "custom_field_type": "dropdown", "default_value": null, "placeholder": null, "placeholder_en": null, "is_required": "Y", "is_employee_edit_flag": "N", "order_no": 2, "last_upd": "2026-02-18 09:12:33", "publish_flag": "Y", "options": [ { "label": "CC001 : ฝ่ายบุคคล", "label_en": "CC001 : ฝ่ายบุคคล", "value": "20240101CC0000000001", "order_no": 1 } ], "value": "20240101CC0000000001" } ] }

Response Fields

FieldTypeDescription
codestringรหัสสถานะ (200 = สำเร็จ)
messagestringข้อความตอบกลับจากระบบ
payloadarrayรายการ Custom Field เรียงตาม order_no จากน้อยไปมาก
payload[].custom_field_config_idstringID ของคอนฟิก Custom Field — ใช้เป็น key อ้างอิงค่าของฟิลด์
payload[].custom_field_modulestringโมดูลของฟิลด์ (คืนค่า document สำหรับเอกสารยื่นคำขอ)
payload[].custom_field_system_idstring | nullID ของ Master Data ที่ฟิลด์ dropdown ดึงตัวเลือกมา (null = ตั้งตัวเลือกเอง)
payload[].custom_field_codestringรหัสอ้างอิงของฟิลด์
payload[].custom_field_labelstringชื่อฟิลด์ (TH)
payload[].custom_field_label_enstringชื่อฟิลด์ (EN)
payload[].custom_field_typestringประเภทฟิลด์ — ดู Field Types
payload[].default_valuemixedค่าเริ่มต้นของฟิลด์
payload[].placeholderstringข้อความตัวอย่างในช่องกรอก (TH)
payload[].placeholder_enstringข้อความตัวอย่างในช่องกรอก (EN)
payload[].is_requiredstringบังคับกรอกหรือไม่ (Y/N)
payload[].is_employee_edit_flagstringพนักงานแก้ไขค่านี้เองได้หรือไม่ (Y/N)
payload[].validation_jsonobjectเงื่อนไขการตรวจสอบข้อมูล — ดู Validation JSON
payload[].order_nonumberลำดับการแสดงฟิลด์
payload[].last_updstringเวลาที่คอนฟิกฟิลด์ถูกแก้ไขล่าสุด (YYYY-MM-DD HH:mm:ss)
payload[].publish_flagstringสถานะเผยแพร่ของฟิลด์ — คืนเฉพาะฟิลด์ที่เป็น Y เท่านั้น
payload[].optionsarrayรายการตัวเลือก มีค่าเฉพาะฟิลด์ dropdown ส่วนประเภทอื่นคืน [] เสมอ — ดู Options
payload[].valuemixedค่าที่บันทึกไว้ในเอกสาร (รูปแบบขึ้นกับ custom_field_type) ถ้ายังไม่เคยกรอกฟิลด์นี้จะเป็น null

Field Types

ประเภทของฟิลด์ที่ระบบรองรับ พร้อมตัวอย่างค่าที่ส่งกลับใน value:

TypeคำอธิบายExample valueหมายเหตุ
textข้อความสั้นบรรทัดเดียว"สมชาย จดหมาย"เหมาะกับ ชื่อ, เบอร์โทรศัพท์
textareaข้อความยาวหลายบรรทัด"หมายเหตุ...\nบรรทัด 2"เหมาะกับ ที่อยู่, รายละเอียดเพิ่มเติม
integerตัวเลขจำนวนเต็ม"10"ไม่รองรับจุดทศนิยม
decimalตัวเลขทศนิยม"1500.50"ระบุตำแหน่งทศนิยมได้ใน validation_json
dropdownรายการเลือกแบบตัวเลือกเดียว"ตัวเลือกที่ 1"ค่าที่คืนคือ value จากรายการใน Options
dateวันที่"2024-05-18"รูปแบบ YYYY-MM-DD
timeเวลา"14:30"รูปแบบ HH:mm (24 ชั่วโมง)
datetimeวันที่และเวลา"2024-05-18 14:30"รูปแบบ YYYY-MM-DD HH:mm

custom_field_type รองรับ 8 ประเภทตามตารางนี้เท่านั้น ฟิลด์ที่ดึงตัวเลือกจาก Master Data ของระบบ (เช่น Cost Center) จะมาเป็น custom_field_type = dropdown คู่กับ custom_field_system_id ที่มีค่า — ไม่มีประเภทชื่อ system แยกต่างหาก

Validation JSON

โครงสร้างของ validation_json ใช้ตรวจสอบความถูกต้องของข้อมูล:

FieldTypeDescription
formatstringรูปแบบข้อมูล: number, text, text_number, free
patternstringRegular Expression สำหรับตรวจสอบข้อมูล
minLengthnumberจำนวนอักขระ/ค่าต่ำสุด (สำหรับตัวเลขคือ Min Value)
maxLengthnumberจำนวนอักขระ/ค่าสูงสุด (สำหรับตัวเลขคือ Max Value)
decimalnumberจำนวนตำแหน่งทศนิยม (ใช้กับ decimal)
min_rangestringวันที่/เวลาเริ่มต้นที่ยอมรับ (ใช้กับ date, time, datetime)
max_rangestringวันที่/เวลาสิ้นสุดที่ยอมรับ (ใช้กับ date, time, datetime)
message_thstringข้อความแจ้งเตือนเมื่อข้อมูลไม่ถูกต้อง (ไทย)
message_enstringข้อความแจ้งเตือนเมื่อข้อมูลไม่ถูกต้อง (อังกฤษ)
  • pattern, message_th, message_en ระบบสร้างให้อัตโนมัติจากค่า format จึงเป็นข้อความมาตรฐานที่กำหนดเองไม่ได้
  • ฟิลด์ที่ไม่ได้ตั้ง format (เช่น integer, decimal, date, time, datetime) จะไม่มี pattern, message_th, message_en ใน response
  • key ที่มีค่าเป็น null จะถูกตัดออกก่อนส่ง response

Validation JSON Examples

"validation_json": { "format": "free", "pattern": "^[\\s\\S]*$", "minLength": 0, "maxLength": 255, "message_th": "กรอกได้ทุกอย่าง", "message_en": "Any input is allowed" }

Options

options จะมีค่าเฉพาะฟิลด์ที่ custom_field_type = dropdown เท่านั้น โดยแบ่งเป็น 2 กรณีที่โครงสร้างต่างกันเล็กน้อย

กรณีที่ 1 — Dropdown ที่ตั้งตัวเลือกเอง

ใช้เมื่อ custom_field_system_id เป็น null — ตัวเลือกมาจากที่ตั้งไว้ตอนสร้าง Custom Field

FieldTypeDescription
labelstringชื่อตัวเลือกที่แสดงผล
valuestringค่าที่บันทึกจริง (ระบบสร้างจาก label)
order_nonumberลำดับการแสดงผล
is_defaultstringมีเฉพาะตัวเลือกที่เป็นค่าเริ่มต้น โดยค่าเป็น Y — ตัวเลือกอื่นจะไม่มี key นี้
"options": [ { "label": "ตัวเลือกที่ 1", "value": "ตัวเลือกที่ 1", "order_no": 1, "is_default": "Y" }, { "label": "ตัวเลือกที่ 2", "value": "ตัวเลือกที่ 2", "order_no": 2 } ]

กรณีที่ 2 — Dropdown ที่ดึงจาก Master Data

ใช้เมื่อ custom_field_system_id มีค่า — ระบบสร้างตัวเลือกจาก Master Data ให้ตอนเรียก API และเรียงลำดับตามรหัสที่อยู่หน้าเครื่องหมาย : ใน label

FieldTypeDescription
labelstringรูปแบบ <รหัส> : <ชื่อ> เช่น CC001 : ฝ่ายบุคคล
label_enstringค่าเดียวกับ label (Master Data ยังไม่มีชื่อภาษาอังกฤษแยก)
valuestringID ของ Master Data — เป็นค่าที่ถูกเก็บในฟิลด์ value
order_nonumberลำดับที่สร้างขึ้นก่อนเรียงลำดับ (กรณีนี้ไม่มี is_default)
"options": [ { "label": "CC001 : ฝ่ายบุคคล", "label_en": "CC001 : ฝ่ายบุคคล", "value": "20240101CC0000000001", "order_no": 1 } ]

Code Examples

curl -X GET "https://openapi.humansoft.co.th/api/v1/open-apis/holiday-change/get-custom-fields?holiday_change_id=MjAyNjA0MzBIQzAwMDAwMDAx" \ -H "Ocp-Apim-Subscription-Key: YOUR_API_KEY"

Error Handling

Missing Parameter (HTTP 400)

{ "code": "400", "message": "Missing required key: holiday_change_id" }

ไม่พบคอนฟิก Custom Field (HTTP 200)

กรณียังไม่เคยตั้งค่า Custom Field ของเอกสารการเปลี่ยนวันหยุด ระบบจะคืน 200 พร้อม payload ว่าง (ไม่ใช่ error):

{ "code": "200", "message": "No custom field document found", "payload": [] }

Notes

  • API นี้ไม่ได้ตรวจสอบว่าเอกสารที่ระบุมีอยู่จริงหรือไม่ — ถ้าส่ง holiday_change_id ที่ไม่มีอยู่จริง จะคืนคอนฟิกครบทุกฟิลด์โดยที่ value เป็น null ทั้งหมด (ไม่ใช่ HTTP 404)
  • payload คืนเฉพาะฟิลด์ที่เผยแพร่แล้วเท่านั้น และเรียงตาม order_no จากน้อยไปมาก จึงนำไปแสดงผลเป็นฟอร์มได้ทันที
  • ใช้ custom_field_config_id เป็น key ในการอ้างอิงค่าของแต่ละฟิลด์เมื่อส่งข้อมูลกลับเข้าระบบ
  • Get Holiday Change List - ดูรายการเอกสารเพื่อเอา holiday_change_id
  • Submit Holiday Change - สร้างเอกสารการเปลี่ยนวันหยุด
  • Update Holiday Change - แก้ไขเอกสารการเปลี่ยนวันหยุด
  • Approve Holiday Change - อนุมัติเอกสารการเปลี่ยนวันหยุด
Last updated on