> For the complete documentation index, see [llms.txt](https://docs.coreway.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coreway.com/coreway-table/automation/flow-control/code-block.md).

# 代碼塊

### 1. 節點功能

透過 JS 或 Python 語言，對輸入的字段進行處理並輸出結果，可以實現更加個性化的數據處理效果。

![image.png](https://273888574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9WI4IMScYYFwRQSZY8Zr%2Fuploads%2FIPregE9aHcia3BkTpv6o%2Fad4b3c49c3d351f695d3d86597c4c6dc.png?alt=media)

### 2. 場景舉例

例如需要實現「車牌號是否限行」的判斷效果，根據當前時間以及車牌號碼來判斷是否限行。

限行規則如下：星期一至星期三，早上 8 點到 10 點，偶數位的車牌不能行駛。

### 3. 配置步驟

1. 設置工作表字段：車牌號碼、是否可以出行，兩個文本字段。
2. 流程管理 - 新建工作流程 - 工作表事件觸發。
3. 配置觸發節點，選擇剛才設置的工作表。

![image.png](https://273888574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9WI4IMScYYFwRQSZY8Zr%2Fuploads%2FBRk064K35zDpCi0BLmUV%2Fa11e69d67e2162906085faa4eda41784.png?alt=media)

4. 添加代碼塊節點，可選 JavaScript 或 Python，這裡選擇 Python。定義 input 對象 `license_plate_number` 為車牌號碼字段，在代碼塊中輸入 Python 代碼，用於判斷車牌號以及當前時間是否限行的規則。

![image.png](https://273888574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9WI4IMScYYFwRQSZY8Zr%2Fuploads%2F4fl1YLJ2OZXinv8Bf5fo%2F26befffd19c0dba4ec8271a84b46331f.png?alt=media)

5. 代碼輸入完成之後，可點擊測試來獲取 output 結果，並定義參數類型為文本；輸出無誤之後，點擊保存。

![image.png](https://273888574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9WI4IMScYYFwRQSZY8Zr%2Fuploads%2FEtxK7MJwMbNqndXGBrgn%2Fdbeb17156c17e661f72831171681c5de.png?alt=media)

6. 再添加「更新數據」節點，將代碼塊輸出的內容對記錄內「是否可以出行」字段進行更新，更新的值選擇代碼塊返回的參數。

![image.png](https://273888574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9WI4IMScYYFwRQSZY8Zr%2Fuploads%2F782ZiijTQnNPxYFvV8RZ%2Fb2f0ef4e96c7883aa0fbf148b863848b.png?alt=media)

7. 配置完成之後，發布工作流程，回到工作表頁面進行新增數據。

### 4. 效果

![20230828161357\_rec\_.gif](https://273888574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9WI4IMScYYFwRQSZY8Zr%2Fuploads%2F23fG7Zg0Oxj8P0fENy6d%2Ffdf3feb1eab72c1baac2b054389dfb4e.gif?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coreway.com/coreway-table/automation/flow-control/code-block.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
