Get Time Adjust Custom Fields
ดึงข้อมูลคอนฟิกและค่าที่บันทึกไว้ของ Custom Field สำหรับเอกสารการขอเพิ่มเวลา
ใช้ API นี้เพื่อดึงฟิลด์เพิ่มเติม (Custom Field) ที่ตั้งค่าไว้สำหรับเอกสารการขอเพิ่มเวลา คืนค่าทั้งโครงสร้างฟิลด์ (config), ตัวเลือก (options), เงื่อนไขการตรวจสอบ (validation_json) และค่าที่บันทึกไว้ในเอกสาร (value)
Endpoint
GET /api/v1/open-apis/time-adjust/get-custom-fieldsสิทธิ์ที่ต้องการ: API Key ต้องมีสิทธิ์ ข้อมูลการยื่นเอกสาร (document:manage)
Request Parameters
Required Parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
time_adjust_id | string | Yes | ID เอกสารการขอเพิ่มเวลา (Base64) | MjAyNjAyMThBQjEyM0NENDU2RUY= |
Response Format
Success Response (HTTP 200)
{
"code": "200",
"message": "Get Data Custom Field Time Adjust 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": "Additional Reason",
"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
| Field | Type | Description |
|---|---|---|
code | string | รหัสสถานะ (200 = สำเร็จ) |
message | string | ข้อความตอบกลับจากระบบ |
payload | array | รายการ Custom Field เรียงตาม order_no จากน้อยไปมาก |
payload[].custom_field_config_id | string | ID ของคอนฟิก Custom Field — ใช้เป็น key อ้างอิงค่าของฟิลด์ |
payload[].custom_field_module | string | โมดูลของฟิลด์ (คืนค่า document สำหรับเอกสารยื่นคำขอ) |
payload[].custom_field_system_id | string | null | ID ของ Master Data ที่ฟิลด์ dropdown ดึงตัวเลือกมา (null = ตั้งตัวเลือกเอง) |
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 | ข้อความตัวอย่างในช่องกรอก (TH) |
payload[].placeholder_en | string | ข้อความตัวอย่างในช่องกรอก (EN) |
payload[].is_required | string | บังคับกรอกหรือไม่ (Y/N) |
payload[].is_employee_edit_flag | string | พนักงานแก้ไขค่านี้เองได้หรือไม่ (Y/N) |
payload[].validation_json | object | เงื่อนไขการตรวจสอบข้อมูล — ดู Validation JSON |
payload[].order_no | number | ลำดับการแสดงฟิลด์ |
payload[].last_upd | string | เวลาที่คอนฟิกฟิลด์ถูกแก้ไขล่าสุด (YYYY-MM-DD HH:mm:ss) |
payload[].publish_flag | string | สถานะเผยแพร่ของฟิลด์ — คืนเฉพาะฟิลด์ที่เป็น Y เท่านั้น |
payload[].options | array | รายการตัวเลือก มีค่าเฉพาะฟิลด์ dropdown ส่วนประเภทอื่นคืน [] เสมอ — ดู Options |
payload[].value | mixed | ค่าที่บันทึกไว้ในเอกสาร (รูปแบบขึ้นกับ 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 ใช้ตรวจสอบความถูกต้องของข้อมูล:
| 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 | ข้อความแจ้งเตือนเมื่อข้อมูลไม่ถูกต้อง (อังกฤษ) |
pattern,message_th,message_enระบบสร้างให้อัตโนมัติจากค่าformatจึงเป็นข้อความมาตรฐานที่กำหนดเองไม่ได้- ฟิลด์ที่ไม่ได้ตั้ง
format(เช่นinteger,decimal,date,time,datetime) จะไม่มีpattern,message_th,message_enใน response - key ที่มีค่าเป็น
nullจะถูกตัดออกก่อนส่ง response
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
options จะมีค่าเฉพาะฟิลด์ที่ custom_field_type = dropdown เท่านั้น โดยแบ่งเป็น 2 กรณีที่โครงสร้างต่างกันเล็กน้อย
กรณีที่ 1 — Dropdown ที่ตั้งตัวเลือกเอง
ใช้เมื่อ custom_field_system_id เป็น null — ตัวเลือกมาจากที่ตั้งไว้ตอนสร้าง Custom Field
| Field | Type | Description |
|---|---|---|
label | string | ชื่อตัวเลือกที่แสดงผล |
value | string | ค่าที่บันทึกจริง (ระบบสร้างจาก label) |
order_no | number | ลำดับการแสดงผล |
is_default | string | มีเฉพาะตัวเลือกที่เป็นค่าเริ่มต้น โดยค่าเป็น 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
| Field | Type | Description |
|---|---|---|
label | string | รูปแบบ <รหัส> : <ชื่อ> เช่น CC001 : ฝ่ายบุคคล |
label_en | string | ค่าเดียวกับ label (Master Data ยังไม่มีชื่อภาษาอังกฤษแยก) |
value | string | ID ของ Master Data — เป็นค่าที่ถูกเก็บในฟิลด์ value |
order_no | number | ลำดับที่สร้างขึ้นก่อนเรียงลำดับ (กรณีนี้ไม่มี is_default) |
"options": [
{
"label": "CC001 : ฝ่ายบุคคล",
"label_en": "CC001 : ฝ่ายบุคคล",
"value": "20240101CC0000000001",
"order_no": 1
}
]Code Examples
cURL
curl -X GET "https://openapi.humansoft.co.th/api/v1/open-apis/time-adjust/get-custom-fields?time_adjust_id=MjAyNjAyMThBQjEyM0NENDU2RUY=" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY"Error Handling
Missing Parameter (HTTP 400)
{
"code": "400",
"message": "Missing required key: time_adjust_id"
}ไม่พบคอนฟิก Custom Field (HTTP 200)
กรณียังไม่เคยตั้งค่า Custom Field ของเอกสารการขอเพิ่มเวลา ระบบจะคืน 200 พร้อม payload ว่าง (ไม่ใช่ error):
{
"code": "200",
"message": "No custom field document found",
"payload": []
}Notes
- API นี้ไม่ได้ตรวจสอบว่าเอกสารที่ระบุมีอยู่จริงหรือไม่ — ถ้าส่ง
time_adjust_idที่ไม่มีอยู่จริง จะคืนคอนฟิกครบทุกฟิลด์โดยที่valueเป็นnullทั้งหมด (ไม่ใช่ HTTP 404) payloadคืนเฉพาะฟิลด์ที่เผยแพร่แล้วเท่านั้น และเรียงตามorder_noจากน้อยไปมาก จึงนำไปแสดงผลเป็นฟอร์มได้ทันที- ใช้
custom_field_config_idเป็น key ในการอ้างอิงค่าของแต่ละฟิลด์เมื่อส่งข้อมูลกลับเข้าระบบ
Related APIs
- Get Adjust List - ดูรายการเอกสารเพื่อเอา
time_adjust_id - Get Adjust Detail - ดูรายละเอียดเอกสารการขอเพิ่มเวลา
- Submit Adjust - สร้างเอกสารการขอเพิ่มเวลา
- Update Adjust - แก้ไขเอกสารการขอเพิ่มเวลา
- Approve Adjust - อนุมัติเอกสารการขอเพิ่มเวลา