--- title: "创建带序列号的ID" slug: "library-app-template-18" updated: 2026-10-22T17:29:30Z published: 2026-10-22T17:29:30Z canonical: "support.tulip.co/library-app-template-18" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.tulip.co/llms.txt > Use this file to discover all available pages before exploring further. # 创建带序列号的ID *此功能可生成序列号 ID* 谁可以使用此功能 截至 r338 版本,Functions 处于生产环境早期访问阶段。如需申请访问权限,请联系您的客户成功经理。 **请[在此处](https://community.tulip.co/t/functions-production-release-available-for-early-access/15658)社区讨论帖中阅读更多内容。** “创建带序列号的ID”功能已针对通用数据模型(Common Data Model)的“操作”(Action)表进行配置。若您希望将其应用于其他表,则需为该特定表设置一个Tulip表连接器。 ![Screenshot 2025-07-22 at 10.59.18.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2010.59.18.png) - [如何创建 HTTP 连接器](https://support.tulip.co/docs/how-to-create-and-configure-an-http-connector-function) - [如何使用表 API](/r230/docs/how-to-use-the-table-api) ## 简介 函数使您的团队能够一次性构建共享或标准化的逻辑,然后在多个应用中重复使用。在本示例中,我们将演示可批量更新多个工单中“状态”字段的函数。 ### 函数流程 函数流程:![Running ID flow v2.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Running%20ID%20flow%20v2.png) ### 操作指南 函数由应用程序中的触发器触发。在函数中,您可以定义需要由调用该函数的触发器提供的输入。 在此特定函数中,我们需要两个输入。![Screenshot 2025-07-21 at 12.41.54.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-21%20at%2012.41.54.png) 此外,该函数还有一个输出,可在应用程序中使用。 ![Screenshot 2025-07-21 at 12.41.59.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-21%20at%2012.41.59.png) 第一个输入是“前缀”变量,第二个是“长度”变量。这两个变量由触发器提供给函数调用。函数利用这些输入来执行。![Screenshot 2025-07-21 at 14.01.58.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-21%20at%2014.01.58.png) 首先,该函数由触发器调用。函数被调用后的第一个操作是生成一个长度为 20 个字符的 ID 占位符,这与 SAP ID 的长度相对应。如果您的操作使用更长的 ID,您可以修改此 ID 占位符以满足您的需求。 ![Screenshot 2025-07-22 at 9.39.26.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%209.39.26.png) 接下来,该函数使用连接器函数,从其配置的表中检索具有指定前缀的最后一个 ID。 ![Screenshot 2025-07-22 at 11.05.43.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.05.43.png) 函数检索到最后一个 ID 后,会检查该 ID 是否存在。![Screenshot 2025-07-22 at 11.07.31.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.07.31.png) 如果该 ID 不存在,则会生成一个新 ID。要生成新 ID,第一步是将 ID 长度设置为与“ID 长度”输入框中提供的值一致。![Screenshot 2025-07-22 at 11.10.51.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.10.51%281%29.png) 第二步是生成实际的 ID。该操作会使用提供的前缀和新指定的 ID 长度,并将数字递增 1。![Screenshot 2025-07-22 at 11.13.47.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.13.47.png) 如果检索到的上一个 ID 存在,该函数将检查 ID 的长度(不包括前缀)。 ![Screenshot 2025-07-22 at 11.21.08.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.21.08.png) 接下来,该函数会检查第二个输入项——“ID长度”数值输入框——是否为空。 ![Screenshot 2025-07-22 at 11.20.05.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.20.05.png) 如果为空,则表示用户仅希望将现有 ID 的数字部分递增。为此,他们首先需要从 ID 中提取该数字。 ![Screenshot 2025-07-22 at 11.22.54.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.22.54.png) 接下来,该函数将之前提取的数字加1。![Screenshot 2025-07-22 at 11.24.03.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.24.03.png) 最后,生成新的ID。![Screenshot 2025-07-22 at 11.26.43.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.26.43.png) 如果“ID长度”输入字段不为空,该函数会检查“ID长度”是否与“最后一个ID”的长度相同。![Screenshot 2025-07-22 at 11.29.40.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.29.40.png) 如果是,则同样不会生成新 ID,而是仅将现有 ID 递增 1。该函数将以与“ID 长度”输入为空时相同的方式提取 ID 编号,将其递增 1,并生成新 ID。 如果“ID 长度”与“上一个 ID”的长度不一致,该函数将生成一个新 ID。为此,第一步是将 ID 长度设置为与“ID 长度”输入框中提供的值一致。![Screenshot 2025-07-22 at 11.10.51.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.10.51%281%29.png) 第二步是生成实际的ID。该操作使用提供的前缀、新指定的ID长度,并将数字递增1。![Screenshot 2025-07-22 at 11.13.47.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.13.47.png) 在函数结尾,会生成一个新的 ID 变量作为函数的输出。该变量可在 ![Screenshot 2025-07-22 at 11.36.43.png](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screenshot%202025-07-22%20at%2011.36.43.png){height="" width=""}应用程序中作为新表记录的ID。 ## 进一步阅读 *如果您想了解更多的函数,请查阅以下其他文档以拓展您的知识* - [函数概述文章](https://support.tulip.co/docs/functions) - [工单表字段更新函数](https://support.tulip.co/docs/work-order-table-fields-update-function) - [工单状态批量更新](https://support.tulip.co/docs/work-order-table-statues-field-update-function)