> 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/yoov-plus/worksheet/worksheet-design/field-type/auto-serial-number.md).

# 自动编号

自动编号字段用于为每一条新记录自动生成一个格式化的唯一标识符（流水号），例如：`PO-20231027-0001`。

## **1. 编号规则组成** <a href="#id-1-number-rule-composition" id="id-1-number-rule-composition"></a>

编号由以下四类元素**按顺序组合**构成，您可以根据业务需求灵活配置：

| 规则类型     | 说明与作用                      | 示例                   |
| -------- | -------------------------- | -------------------- |
| **固定字符** | 作为连接符或业务标识，区分不同类型的单据。      | `PO-`、`INV-`、`-`     |
| **提交时间** | 嵌入记录的创建时间，支持丰富的自定义格式。      | `20231027`、`2023-Q4` |
| **表单字段** | 引用其他字段的值（如客户简称），使编号包含业务信息。 | `BJ`（取自“区域”字段）       |
| **自动计算** | 核心的流水数字部分，可设置初始值、位数和重置周期。  | `0001`、`042`         |

<figure><img src="/files/FcDwxWSBXNIdwy26YhTj" alt=""><figcaption></figcaption></figure>

## **2. 自动计算规则详解** <a href="#id-2-auto-calculate-rule-detail" id="id-2-auto-calculate-rule-detail"></a>

这是流水号的核心，需要重点配置。

**2.1 位数与固定规则**

* **指定位数**：可设置位数（如5位），系统会自动补零（如`00001`）。
* **位数固定**：
  * **勾选**：编号达到上限（如`99999`）后，**将重置从1开始**。
  * **不勾选**：编号达到上限后，**自动增加位数**继续（如`100000`）。

**2.2 重置周期**\
流水号可按以下周期自动归零，重新开始计数：

* **每天重置**、**每周重置**、**每月重置**、**每年重置**。
* **示例**：设置“每天重置”且初始值为`1`，则每日的第一张单号都为`xxxx-0001`。

<figure><img src="/files/sjIShwSN5NPZyPjSI9HC" alt=""><figcaption></figcaption></figure>

**2.3 初始值**

* 定义计数开始的基数。例如初始值为`100`，则第一条编号的流水部分为`100`，下一条为`101`。
* **重要提示**：**初始值不与现有记录数累加**。若已有10条记录（最大编号为`10`），此时将初始值改为`100`，则下一条新记录的编号将为`100`（而非`110`）。如需让现有编号也重新开始，需使用 **“重置自动编号”** 功能。

## **3. 提交时间格式说明** <a href="#id-3-submit-time-format-guide" id="id-3-submit-time-format-guide"></a>

可将记录的创建时间按需嵌入编号。常用格式符号如下：

<table data-header-hidden><thead><tr><th width="160.111083984375"></th><th width="160.111083984375">规则符号</th><th>输出效果</th></tr></thead><tbody><tr><td>年</td><td>YY</td><td>98 99 …… 21 22 （只是显示年份后两位数字）</td></tr><tr><td></td><td>YYYY</td><td>1998 1999 ……2021 2022</td></tr><tr><td>月</td><td>M</td><td>1 2 3 …… 11 12</td></tr><tr><td></td><td>MM</td><td>01 02 03 …… 11 12 （小于10的会在前面补0）</td></tr><tr><td></td><td>MMM</td><td>1月 2月 …… 11月 12月</td></tr><tr><td></td><td>MMMM</td><td>一月 二月 ……十一月 十二月</td></tr><tr><td>日</td><td>D</td><td>1 2 3 …… 29 30 31</td></tr><tr><td></td><td>DD</td><td>01 02 03 …… 29 30 31 （小于10的会在前面补0）</td></tr><tr><td>星期</td><td>d</td><td>0 1 …… 5 6</td></tr><tr><td></td><td>dd</td><td>日 一 …… 六</td></tr><tr><td></td><td>ddd</td><td>周日 周一 ……周五 周六</td></tr><tr><td></td><td>dddd</td><td>星期日 星期一 …… 星期五 星期六</td></tr><tr><td>1年内的周数</td><td>w</td><td>1 2 3 …… 52 53</td></tr><tr><td></td><td>ww</td><td>01 02 03 …… 52 53</td></tr><tr><td>季度</td><td>Q</td><td>1 2 3 4</td></tr><tr><td>上/下午</td><td>A</td><td>上午 下午</td></tr><tr><td></td><td>a</td><td>上午 下午</td></tr><tr><td>时</td><td>H</td><td>0 1 2 …… 22 23（大写是24小时制）</td></tr><tr><td></td><td>HH</td><td>00 01 02 …… 22 23</td></tr><tr><td></td><td>h</td><td>1 2 3 …… 10 11（小写是12小时制）</td></tr><tr><td></td><td>hh</td><td>01 02 03 …… 10 11</td></tr><tr><td>分</td><td>m</td><td>0 1 2 …… 58 59</td></tr><tr><td></td><td>mm</td><td>00 01 02 …… 58 59</td></tr><tr><td>秒</td><td>s</td><td>0 1 2 …… 58 59</td></tr><tr><td></td><td>ss</td><td>00 01 02 …… 58 59</td></tr><tr><td>毫秒</td><td>SSS</td><td>001 002 003 …… 998 999</td></tr></tbody></table>

**格式示例**：

* `YYYYMMDD` → `20231027`
* `YY-MM-DD` → `23-10-27`
* `YYYYMMDD HH:mm:ss` → `20231027 14:09:30`

## **4. 管理与重置** <a href="#id-4-manage-reset" id="id-4-manage-reset"></a>

* **规则排序**：通过拖拽调整各规则元素（固定字符、时间、字段等）的**前后顺序**，以改变编号的最终格式。
* **重置自动编号**：
  * **入口**：仅当工作表已添加自动编号字段时显示。
  * **作用**：将指定自动编号字段的流水计数**初始化**为当前设置的初始值，**不影响历史记录**。
  * **注意**：此功能**不适用于子表**内的自动编号。若需重置，需先将子表转为独立实体工作表。


---

# 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 dynamically by asking a question.

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

```
GET https://docs.coreway.com/yoov-plus/worksheet/worksheet-design/field-type/auto-serial-number.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
