跳转至

Function-backed actions(函数支持的操作(Function-backed actions))

In an action type, rules define the ways objects should change when the action is applied. Many action types can be defined using simple rules which allow you to create, modify, and delete objects, or create and delete links between objects.

In some cases, however, simple rules are not sufficient to describe the changes that you want to make. For example, you may want to:

  • Modify multiple objects that are currently linked together. For example, you may want to set the status field of an Incident object to Closed, and also set the status of all linked Alert objects to Resolved.
  • Modify an object's properties based on some more complex logic. For example, you may want to compute a value based on some business logic that reads data from several objects, then write that value into an object property.
  • Create several different types of objects and set up links between them.

To support use cases like these, action types can be configured to call a function that defines the logic of how objects should be modified. These action types are often referred to as function-backed actions. By using a function, you can create action types of any level of complexity, reading any number of objects and modifying objects as you see fit.

Although function-backed action types are very flexible, you should note that they are subject to both action type limits and function execution limits.

Get started with function-backed actions by following the tutorial.


中文翻译

函数支持的操作(Function-backed actions)

在操作类型中,规则(Rules)定义了应用操作时对象应如何变化。许多操作类型可以通过简单的规则来定义,允许你创建、修改和删除对象,或在对象之间创建和删除链接。

然而,在某些情况下,简单的规则不足以描述你想要进行的更改。例如,你可能需要:

  • 修改当前相互链接的多个对象。例如,你可能希望将Incident对象的status字段设置为Closed,同时将所有关联的Alert对象的status设置为Resolved
  • 基于某些更复杂的逻辑修改对象的属性。例如,你可能希望根据从多个对象读取数据的业务逻辑计算一个值,然后将该值写入对象属性。
  • 创建几种不同类型的对象并建立它们之间的链接。

为了支持此类用例,操作类型可以配置为调用一个函数(Function),该函数定义了对象应如何修改的逻辑。这些操作类型通常被称为函数支持的操作(Function-backed actions)。通过使用函数,你可以创建任意复杂程度的操作类型,读取任意数量的对象,并根据需要修改对象。

尽管函数支持的操作类型非常灵活,但需要注意的是,它们同时受到操作类型限制(Action type limits)函数执行限制(Function execution limits)的约束。

通过教程(Tutorial)开始使用函数支持的操作。