Skip to Content
🚀 Welcome to Humansoft Open API Documentation

Get Leave Custom Fields

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

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

Endpoint

GET /api/v1/open-apis/time-leave/get-custom-fields

Request Parameters

Required Parameters

ParameterTypeRequiredDescriptionExample
time_leave_idstringYesID เอกสารการลา (Base64)MjAyNjA0MzBUSTAwMDAwMDAx

Validation Rules

กฎรายละเอียด
time_leave_idต้องระบุ และต้องมีคอนฟิก Custom Field สำหรับโมดูล time_leave

Code Examples

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

FieldTypeDescription
codestringรหัสสถานะ (200 = สำเร็จ)
messagestringข้อความตอบกลับจากระบบ
payloadarrayรายการ Custom Field
payload[].custom_field_config_idstringID ของคอนฟิก Custom Field
payload[].custom_field_modulestringโมดูลของฟิลด์ (เช่น document)
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ข้อความ placeholder (TH)
payload[].placeholder_enstringข้อความ placeholder (EN)
payload[].is_requiredstringบังคับกรอกหรือไม่ (Y/N)
payload[].validation_jsonobjectเงื่อนไขการตรวจสอบข้อมูล — ดู Validation JSON
payload[].optionsarrayรายการตัวเลือกสำหรับ dropdown/system — ดู Options
payload[].valuemixedค่าที่บันทึกไว้ในเอกสาร (รูปแบบขึ้นกับ 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 ใช้ตรวจสอบความถูกต้องของข้อมูล:

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ข้อความแจ้งเตือนเมื่อข้อมูลไม่ถูกต้อง (อังกฤษ)

Validation JSON Examples

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

Options

รายการตัวเลือกสำหรับฟิลด์ประเภท dropdown หรือ system:

FieldTypeDescription
labelstringชื่อตัวเลือกที่แสดงผล (ภาษาไทย)
label_enstringชื่อตัวเลือกที่แสดงผล (ภาษาอังกฤษ)
valuestringค่าข้อมูลที่บันทึกจริง
order_nonumberลำดับการแสดงผล
is_defaultstringเป็นค่าเริ่มต้นหรือไม่ (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" }
  • Get Leave List - ดูรายการเอกสารการลาเพื่อเอา time_leave_id
  • Submit Leave - สร้างเอกสารคำขอลา
  • Approve Leave - อนุมัติเอกสารคำขอลา
Last updated on