Get Leave Custom Fields
ดึงข้อมูลคอนฟิกและค่าที่บันทึกไว้ของ Custom Field สำหรับเอกสารการลา
ใช้ API นี้เพื่อดึงฟิลด์เพิ่มเติม (Custom Field) ที่ตั้งค่าไว้สำหรับเอกสารการลา คืนค่าทั้งโครงสร้างฟิลด์ (config) และข้อมูลที่บันทึกไว้ในเอกสาร (value)
Endpoint
GET /api/v1/open-apis/time-leave/get-custom-fieldsRequest Parameters
Required Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
time_leave_id | string | Yes | ID เอกสารการลา (Base64) | MjAyNjA0MzBUSTAwMDAwMDAx |
Validation Rules
| กฎ | รายละเอียด |
|---|---|
time_leave_id | ต้องระบุ และต้องมีคอนฟิก Custom Field สำหรับโมดูล time_leave |
Code Examples
cURL
curl -X GET "https://openapi.humansoft.co.th/api/v1/open-apis/time-leave/get-custom-fields?time_leave_id=MjAyNjA0MzBUSTAwMDAwMDAx" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY"Response Format
Success Response (HTTP 200)
{
"code": "200",
"message": "Get Data Custom Field Time Leave Success",
"payload": [
{
"custom_field_config_id": "20240101CF0004",
"custom_field_module": "document",
"custom_field_code": "CF0004",
"custom_field_label": "เหตุผลการลาเพิ่มเติม",
"custom_field_label_en": "Additional Leave Reason",
"custom_field_type": "textarea",
"default_value": null,
"placeholder": "ระบุเหตุผล",
"placeholder_en": "Enter reason",
"is_required": "N",
"validation_json": {
"format": "free",
"pattern": "^[\\s\\S]*$",
"minLength": 0,
"maxLength": 500,
"message_th": "กรอกได้สูงสุด 500 ตัวอักษร",
"message_en": "Maximum 500 characters"
},
"options": [],
"value": "ไปต่างจังหวัดร่วมงานครอบครัว"
}
]
}Response Fields
| Field | Type | Description |
|---|---|---|
code | string | รหัสสถานะ (200 = สำเร็จ) |
message | string | ข้อความตอบกลับจากระบบ |
payload | array | รายการ Custom Field |
payload[].custom_field_config_id | string | ID ของคอนฟิก Custom Field |
payload[].custom_field_module | string | โมดูลของฟิลด์ (เช่น document) |
payload[].custom_field_code | string | รหัสอ้างอิงของฟิลด์ |
payload[].custom_field_label | string | ชื่อฟิลด์ (TH) |
payload[].custom_field_label_en | string | ชื่อฟิลด์ (EN) |
payload[].custom_field_type | string | ประเภทฟิลด์ — ดู Field Types |
payload[].default_value | mixed | ค่าเริ่มต้นของฟิลด์ |
payload[].placeholder | string | ข้อความ placeholder (TH) |
payload[].placeholder_en | string | ข้อความ placeholder (EN) |
payload[].is_required | string | บังคับกรอกหรือไม่ (Y/N) |
payload[].validation_json | object | เงื่อนไขการตรวจสอบข้อมูล — ดู Validation JSON |
payload[].options | array | รายการตัวเลือกสำหรับ dropdown/system — ดู Options |
payload[].value | mixed | ค่าที่บันทึกไว้ในเอกสาร (รูปแบบขึ้นกับ custom_field_type) |
Field Types
ประเภทของฟิลด์ที่ระบบรองรับ พร้อมตัวอย่างค่าที่ส่งกลับใน value:
| Type | คำอธิบาย | Example value | หมายเหตุ |
|---|---|---|---|
text | ข้อความสั้นบรรทัดเดียว | "สมชาย จดหมาย" | เหมาะกับ ชื่อ, เบอร์โทรศัพท์ |
textarea | ข้อความยาวหลายบรรทัด | "หมายเหตุ...\nบรรทัด 2" | เหมาะกับ ที่อยู่, รายละเอียด |
integer | ตัวเลขจำนวนเต็ม | "10" | ไม่รองรับจุดทศนิยม |
decimal | ตัวเลขทศนิยม | "1500.50" | ระบุตำแหน่งทศนิยมใน validation_json |
dropdown | รายการเลือกแบบเดียว | "01" | ส่งคืนเป็น 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 |
system | ข้อมูลจาก Master Data | "CC001" | เช่น รหัสแผนก, รหัสโครงการ |
Validation JSON
โครงสร้างของ validation_json ใช้ตรวจสอบความถูกต้องของข้อมูล:
| Field | Type | Description |
|---|---|---|
format | string | รูปแบบข้อมูล: number, text, text_number, free |
pattern | string | Regular Expression สำหรับตรวจสอบข้อมูล |
minLength | number | จำนวนอักขระ/ค่าต่ำสุด (สำหรับตัวเลขคือ Min Value) |
maxLength | number | จำนวนอักขระ/ค่าสูงสุด (สำหรับตัวเลขคือ Max Value) |
decimal | number | จำนวนตำแหน่งทศนิยม (ใช้กับ decimal) |
min_range | string | วันที่/เวลาเริ่มต้น (ใช้กับ date, time, datetime) |
max_range | string | วันที่/เวลาสิ้นสุด (ใช้กับ date, time, datetime) |
message_th | string | ข้อความแจ้งเตือนเมื่อข้อมูลไม่ถูกต้อง (ไทย) |
message_en | string | ข้อความแจ้งเตือนเมื่อข้อมูลไม่ถูกต้อง (อังกฤษ) |
Validation JSON Examples
Free Text
"validation_json": {
"format": "free",
"pattern": "^[\\s\\S]*$",
"minLength": 0,
"maxLength": 255,
"message_th": "กรอกได้ทุกอย่าง",
"message_en": "Any input is allowed"
}Options
รายการตัวเลือกสำหรับฟิลด์ประเภท dropdown หรือ system:
| Field | Type | Description |
|---|---|---|
label | string | ชื่อตัวเลือกที่แสดงผล (ภาษาไทย) |
label_en | string | ชื่อตัวเลือกที่แสดงผล (ภาษาอังกฤษ) |
value | string | ค่าข้อมูลที่บันทึกจริง |
order_no | number | ลำดับการแสดงผล |
is_default | string | เป็นค่าเริ่มต้นหรือไม่ (Y/N) |
ตัวอย่าง Options
"options": [
{
"label": "ตัวเลือกที่ 1",
"label_en": "Option 1",
"value": "01",
"order_no": 1,
"is_default": "Y"
},
{
"label": "ตัวเลือกที่ 2",
"label_en": "Option 2",
"value": "02",
"order_no": 2,
"is_default": "N"
}
]Error Responses
Missing Parameter (HTTP 400)
{
"code": "400",
"message": "Missing required key: time_leave_id"
}Related APIs
- Get Leave List - ดูรายการเอกสารการลาเพื่อเอา
time_leave_id - Submit Leave - สร้างเอกสารคำขอลา
- Approve Leave - อนุมัติเอกสารคำขอลา
Last updated on