> 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.md).

# 脚本

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-f77adfe209ae633c17f4cc740f8f47c5c9f541fe%2FBildschirmfoto%202024-05-08%20um%2009.43.25.png?alt=media" alt=""><figcaption></figcaption></figure>

{% embed url="<https://youtu.be/n8NpWWIjmlA>" %}
DocBits 文档脚本说明：在文档工作流中自动执行自定义逻辑
{% endembed %}

#### 概述

DocBits 中的脚本通常使用系统支持的脚本语言 Python 编写。脚本会在文档处理工作流期间触发，用于应用复杂的业务逻辑，或在数据进一步处理或存储之前确保数据的完整性和准确性。

#### 主要功能和选项

1. **脚本管理**：
   * **名称**：为每个脚本指定一个唯一名称，以便识别。
   * **文档类型**：将脚本关联到特定的文档类型，确定脚本适用于哪些文档。
   * **触发时机**：定义脚本何时触发（例如，文档上传时、数据导出前、数据验证后）。
   * **启用/停用状态**：管理员可以启用或停用脚本，而无需删除脚本，从而灵活地进行测试和部署。
2. **脚本编辑器**：
   * 提供用于编写和编辑脚本的界面。编辑器通常支持语法高亮、错误高亮和其他辅助脚本开发的功能。
   * **脚本示例**：脚本可以执行多种操作，例如遍历发票行项目以验证总额，或移除不符合特定条件的条目。

<figure><img src="https://1870485400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlPczlNw8zzYNLfjfispX%2Fuploads%2Fgit-blob-aedd3c173f4526dbffd873058be8105e798f9ff8%2FBildschirmfoto%202024-05-08%20um%2009.43.37.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# 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.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.
