> For the complete documentation index, see [llms.txt](https://docs.docbits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.docbits.com/chinese/guan-li-yu-she-zhi/settings/global-settings/document-types/script/script-activation-and-management.md).

# 脚本启用与管理

管理员可以使用 **Scripts** 管理文档类型的处理规则。本指南介绍在哪里查找脚本、如何启用或停用脚本，以及如何安全地修改已发布的脚本。

## 查找脚本

1. 打开 **Settings → Document Types**。
2. 在要管理的文档类型上，选择 **Scripts**。该页面会列出此文档类型的脚本。
3. 按名称搜索，或使用 **All**、**Active** 和 **Inactive** 缩小列表范围。你也可以按名称或修改日期排序。

每张卡片都显示脚本名称、触发器、版本和状态。铅笔图标可打开编辑器；复制图标可复制脚本。**New** 会打开新脚本的编辑器。

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-ebfeac063d9db34469f8feb213a7decf29b3c1e9%2Fdbdc157-scripts-list-inactive-en.png?alt=media" alt="Invoice 文档类型的脚本列表，其中包含一个停用的文档示例，以及 All、Active、Inactive 筛选项"><figcaption><p>更改脚本前，请检查脚本卡片右侧显示的状态。</p></figcaption></figure>

## 启用或停用脚本

使用脚本卡片上的 **Active/Inactive** 开关。更改会立即保存；列表计数会更新以显示更改结果。停用的脚本仍可查看或编辑，但不会在文档处理中运行。

**创建脚本后请检查其状态。** 在当前的 Sandbox 界面中，保存新脚本会创建一个启用状态的版本，并将卡片设为 **Active**。如果脚本只是草稿或测试示例，请将其切换为 **Inactive**。

## 修改现有脚本

1. 选择脚本卡片或其铅笔图标。已发布的版本为只读，因此不能直接在其上输入内容。
2. 在 **Version History** 中，选择要修改版本上的铅笔图标。这会基于该版本创建一个 **Draft**。
3. 编辑草稿并选择 **Save** 图标。保存前，请检查名称、文档类型、触发器和代码。
4. 在测试环境中使用有代表性的文档测试修改后的脚本。准备就绪后，在 **Version History** 中选择该草稿的勾选图标，将其设为启用版本。
5. 返回 **Scripts** 列表，检查卡片上的 **Active/Inactive** 开关。**Version History** 中标记为 **ACTIVE** 的版本表示当前选定的版本；卡片开关则控制脚本是否运行。

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-5856b9398a3e3bbfb03e32dbad1e40dfb8ae6072%2Fdbdc157-script-published-version-en.png?alt=media" alt="已发布的脚本版本以只读方式显示，并提示将其克隆为草稿"><figcaption><p>已发布的版本不能直接编辑。请使用 Version History 中的铅笔图标创建草稿。</p></figcaption></figure>

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-9bd88d1c3b53ac94616e530398819158280b8d42%2Fdbdc157-script-editable-draft-en.png?alt=media" alt="Version History 中可编辑的草稿，旁边显示当前启用的脚本版本"><figcaption><p>将草稿设为启用版本前，请先保存并检查。</p></figcaption></figure>

有关脚本示例和可用函数，请参阅 [DocBits 中的脚本编写](/chinese/guan-li-yu-she-zhi/settings/global-settings/document-types/script/scripting-in-docbits.md)。


---

# 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.docbits.com/chinese/guan-li-yu-she-zhi/settings/global-settings/document-types/script/script-activation-and-management.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.
