# 自訂欄位

## 自訂類型

自訂欄位共分為四種用途，分別套用於「客戶」、「工單」資料關聯

| 代碼 | 名稱                                                | 描述                                             |
| -- | ------------------------------------------------- | ---------------------------------------------- |
| 0  | <p><strong>客戶</strong><br><strong>表單</strong></p> | 即從原本表單額外新增欄位，例如客戶的體重、血型...等，此種欄位屬於**表單欄位。**    |
| 1  | <p><strong>客戶</strong><br><strong>表格</strong></p> | 即從原本表單新增一對多的關聯，例如客戶的多筆購買紀錄，即屬於**關聯表格。**        |
| 2  | <p><strong>工單</strong><br><strong>表單</strong></p> | 即從原本表單額外添新增欄位，例如工單的批號、處理狀態...等，此種欄位屬於**表單欄位**。 |
| 3  | <p><strong>工單</strong><br><strong>表格</strong></p> | 即從原本表單新增一對多的關聯，例如工單的多筆運送紀錄，即屬於**關聯表格**。        |

## 欄位類型

自訂欄位目前共有以下類型，各代碼分別代表不同的儲存型態

| 代碼 | 欄位類型 |
| -- | ---- |
| 0  | 數字欄位 |
| 1  | 文字欄位 |
| 2  | 布林值  |
| 3  | 日期   |
| 4  | 時間   |
| 5  | 日期時間 |
| 6  | 單選   |
| 7  | 多選   |

其中 6(單選) 以及 7(多選) 擁有 options 參數，此欄位以 \
JSON 格式紀錄選項，下面以血型為範例：

```javascript
[
    { "text":"A型",  "value": "A"},
    { "text":"B型",  "value": "B"},
    { "text":"AB型", "value": "AB"},
    { "text":"O型",  "value": "O"}
]
```

即從原本的表單額外添加的欄位，例如 `客戶` 的 `體重`，此種欄位屬於 **動態表單欄位**

即從原本的表單添加 "一對多" 的關聯，例如 `客戶` 的 `購買紀錄`，即屬於 **動態關聯表格**

## 查詢系統自訂欄位

目前系統現有的自訂欄位

```javascript
GET https://{API_DOMAIN}/api/v1/cz-col
```

```javascript
curl -X GET
    -H "Content-Type: application/json:Authorization: Bearer eyJhbGciOiJIUzI1NiI..." https://{API_HOST}/api/v1/cz-col
```

### Parameters

| PARAMETER    | REQUIRED | DEFAULT | TYPE   | DESCRIPTION                                                                                                           |
| ------------ | -------- | ------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| page         | false    | 1       | Number | 目前在第幾頁                                                                                                                |
| per\_page    | false    | 15      | Number | 每頁呈現多少筆                                                                                                               |
| category\_id | false    | NULL    | Number | [動態欄位分類](https://help.firstline.cc/developer/api/hui-ying-wu-jian-ge-shi#dong-tai-lan-wei-fen-lei-czcolcategory) 的 id |
| types        | false    | NULL    | Number | 0: 客戶動態表單欄位 1: 客戶動態關聯表格 2: 工單動態表單欄位 3: 工單動態關聯表格                                                                       |

### Response

| PROPERTY | TYPE             | DESCRIPTION                                                        |
| -------- | ---------------- | ------------------------------------------------------------------ |
| data     | Array of objects | [動態欄位陣列](/developer/api/response-object.md#dong-tai-lan-wei-czcol) |
| meta     | Object           | Pagination meta                                                    |

```javascript
{
    "data": [
        {
            "id": 1,
            "name": "Cyril223",
            "description": "Assumenda est corrupti voluptas aut. Beatae quisquam ex asperiores sit ullam.",
            "is_allowed_null": true,
            "default": null,
            "type": 4,
            "category_id": null,
            "category": null,
            "creater_id": null,
            "creater": null
        }
    ],
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 10,
        "per_page": 1,
        "to": 1,
        "total": 10
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.firstline.cc/developer/api/custom-field.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
