Develop and use custom components

更新时间:
复制 MD 格式

This topic describes how to develop custom components in the code-based development mode and use them in both the code-based and visual development modes.

1. Overview

During flow development, developers can extract common operations, such as checking the logon status for a webpage, into custom components. These components can be reused across multiple automation flows.

2. Develop and publish custom components

Note

Currently, you can publish components only in the code-based development mode.

  1. Open the editor and navigate to the code development interface. In the project panel on the left, right-click the project folder and select New Flow.

  2. Create a child flow with two methods: add and subtract.

  3. Publish the flow as a cloud component.

  4. After the component is published, you can view it in the Console - Enterprise Applications - Enterprise Component List.

3. Use custom components

3.1 Use custom components in code-based development mode

  1. In the menu bar of the code project interface, click Project to open component management. From the list of cloud components, select the component that you want to install.

  2. In the code editor, import the module from the custom component and then call the functions in the module. This process is similar to importing a third-party package in Python.

3.2 Use custom components in visual development mode

  1. In the menu bar of the visual project interface, click Project to open component management. From the list of cloud components, select the component that you want to install.

  2. Create four variables. Use v_p1 and v_p2 as input parameters for the custom component and assign them the values 1 and 2. Use v_result_sum and v_result_subtract to store the results calculated by the component.

  3. In the Call Custom Script widget, import the module from the custom component and then call its functions. This process is similar to importing a third-party package in Python. The variables that you created can be used directly in the script. For more information about using variables in custom scripts, see Call a custom script.

  4. The log records the calculation results as 3 and 1.