Number | Description | ||
---|---|---|---|
1 | Use the require() function at the start of the code to import Node.js modules for use in the custom action. In the sample code, the action is imports the request module to make simple HTTP calls to third-party systems.
| ||
2 | this.id—Attribute that is used as a unique identifier for the custom action. | ||
3 | this.label—Attribute that specifies the name of the custom action.
| ||
4 | this.input—JSON attribute that defines the input fields to display when configuring the action in a workflow. There are three JSON keys for which you need to assign values: • title—(required) Used internally as an identifier • type—(required) Used internally. The value for this key should always be set to object and should not be changed. • properties—required) A JSON attribute that defines the input fields and validation conditions, if any, that appear for the action. Each input field should have a unique key such as first_name and define values for the following items: ◦ title—(required) The label that appears for the field such as First Name. ◦ type—(required) The type of the field. Valid types are string, object, array, and any ◦ description—(optional) A message that appears as a tooltip. ◦ minLength—(optional) Specifies the minimum number of characters that must be specified.
| ||
5 | this.output— A JSON attribute that defines the output fields that the action returns and makes available in the rest of the workflow. There are three JSON keys for which you need to assign values: • title—(required) Used internally as an identifier. • type—(required) Used internally. The value for this key should always be set to object and should not be changed. • properties—(required) A JSON attribute that defines the output fields. Each output field should have a unique key such as status and define values for the following items: ◦ title—(required) The label that appears for the field, such as status. ◦ type—(required) The type of the field. Valid types are string, object, array, and any. | ||
6 | this.execute—Function that defines the program logic that runs when the action is executed within a workflow. The function must define the following two function parameters: • input—A JSON object that contains the values of the input parameters at workflow execution time. The values can be referenced using the input field keys as defined in the this.input attribute of the action. • output—A callback function that must be called to pass the output values to the workflow. It indicates that the action is completed. The function is in the form callback(err,output): ◦ err—Used to report any errors that may have occurred to the workflow. If no errors occur, then use null. ◦ output—A JSON object with values for each of the keys defined in the this.output attribute of the action. |
If you migrate from ThingWorx Flow 8.4.x to ThingWorx Flow 8.5, custom actions that were created in ThingWorx Flow 8.4.x continue to work in ThingWorx Flow 8.5. You can add localization support for input and output fields of the custom action. However, you cannot localize the label of the custom action that was created in ThingWorx Flow 8.4.x. |