跳转至

Custom functions(自定义函数)

Custom functions are particularly useful when a workflow requires rich text-formatted inputs, or if a workflow outputs rich text-formatted content. Function inputs can be rich or plain text, and you can choose whether outputs should be rich or plain text as well. Note that your function should accept Markdown if you require rich text inputs.

:::callout{theme="neutral"} This feature is compatible with functions that take a single string as input, and have an output of type string, Boolean, date, double, float, integer, or long. :::

Use custom functions in Notepad

To use custom functions in Notepad, you must first create a function. Functions can be written in TypeScript or Python; refer to the function documentation for use cases, supported features and guides on function creation. Once you have created a custom function, follow the steps below to use it in Notepad:

  1. In Notepad, open or create a document or document template. Populate the document with content, and select the function input in one of two ways:
  2. Manually highlight the relevant content and select Edit with AIP in the toolbar.
  3. Place your cursor on the relevant content and select Edit with AIP in the toolbar. A block-level selection will automatically be made for you.

:::callout{theme="neutral"} If AIP is not enabled for your enrollment, custom functions in Notepad are still available. Instead of Edit with AIP, select Edit with functions in the toolbar and disregard step two. The 'Edit with functions' option in the toolbar :::

  1. When your selection is made, a pop-up menu will appear. Choose the Functions option to edit the selection with a custom function.
  2. In the function pop-up window, select a function and the function's input type. Choose between plain text or Markdown in the Function input dropdown menu.

Select the function input format.

  1. Optionally preview the input, and run the function.
  2. View the function output, and choose whether the output should be plain text or formatted with Markdown. By default, the output type will be the same as the input type.

Select the function output format.

  1. Insert the output into your document by selecting Replace.

中文翻译

自定义函数

当工作流需要富文本格式的输入,或工作流输出富文本格式的内容时,自定义函数(Custom functions)尤为实用。函数输入可以是富文本或纯文本,您也可以选择输出应为富文本还是纯文本。请注意,如果您需要富文本输入,您的函数应支持Markdown格式。

:::callout{theme="neutral"} 此功能适用于接受单个字符串作为输入,且输出类型为字符串、布尔值、日期、双精度浮点数、浮点数、整数或长整型的函数。 :::

在记事本中使用自定义函数

要在记事本(Notepad)中使用自定义函数,您必须首先创建一个函数。函数可以使用TypeScript或Python编写;有关用例、支持的功能以及函数创建指南,请参阅函数文档。创建自定义函数后,请按照以下步骤在记事本中使用它:

  1. 在记事本中,打开或创建一个文档或文档模板。在文档中填充内容,并通过以下两种方式之一选择函数输入:
  2. 手动高亮相关内容,然后在工具栏中选择使用AIP编辑
  3. 将光标置于相关内容上,然后在工具栏中选择使用AIP编辑。系统将自动为您进行块级选择。

:::callout{theme="neutral"} 如果您的注册环境中未启用AIP,记事本中的自定义函数仍然可用。此时请选择工具栏中的使用函数编辑,并跳过第二步。 工具栏中的'使用函数编辑'选项 :::

  1. 完成选择后,将出现一个弹出菜单。选择函数选项以使用自定义函数编辑所选内容。
  2. 在函数弹出窗口中,选择一个函数及该函数的输入类型。在函数输入下拉菜单中选择纯文本或Markdown格式。

选择函数输入格式。

  1. 可选地预览输入内容,然后运行函数。
  2. 查看函数输出,并选择输出应为纯文本还是使用Markdown格式。默认情况下,输出类型将与输入类型相同。

选择函数输出格式。

  1. 选择替换将输出内容插入到文档中。