Coercing of Activity Input, Output, and Trigger Reply Fields
In the OSS marked Activity input, output, or trigger reply configuration, if you have defined a parameter, but have not defined or cannot define a schema for the parameter, you can coerce the parameter to take the value from a schema that you dynamically define during design time. This feature is particularly useful for apps that were created in Project Flogo and imported to Flogo. Such apps most likely have activities for which input parameters or output are not defined with a schema.
Currently, coercion of parameters is supported only for the following data types:
- array
- object
- param
- any
After you enter the schema, it is displayed in a tree format under Activity inputs, Output tab, or Trigger reply in the mapper. All subsequent activities also display the elements of the schema under the Activity in the Upstream Output. The schema elements are now available for you to map.
Important Considerations
- Coercion is supported only in the Default category activities which are the activities marked as OSS, except for the Return and Start a SubFlow activities. These two activities display flow-level data. The flow-level inputs and outputs can be entered or modified only on the Flow Inputs & Outputs accordion tab, hence they cannot be coerced from the Input tab of the Activity itself.
- Currently, coercion is supported only for top-level parameters. Nested coercion (for example, an object within an object) is not supported.
- Currently, coercing a schema for trigger input is not supported. The coercing option is not available on the Map to Flow Inputs tab in the trigger configuration. This is because the parameters you see on this tab are flow input parameters and are not related to the trigger. You have the option to coerce these parameters on the Input tab of the Flow Inputs & Outputs accordion tab.
- After you have mapped a child element within a parameter, if you change the name of the parent or the child, your mapping is lost. However, if you change the data type of the element, the mapping is preserved, but you see an error related to the mismatch in data type.
- The schema you enter is preserved when you export and import the app.
- If you edit the schema at a later time, as long as you click Apply after editing, your edits are displayed in the mapper. You must then click Save in the mapper to persist your schema changes.
- You cannot coerce a parameter or edit its schema in any activity displayed in a subflow. For example, if the OracleDatabaseQuery activity is displayed in both the main flow and the subflow, you cannot edit the schema of any of its parameters in the subflow. But you can edit the schema of the OracleDatabaseQuery activity in the main flow. This is because the subflow activity input and output schemas are inherited from the main flow. There is a possibility that the same subflow could be used in multiple main flows, so if you edit an activity in the subflow it could break another main flow that uses the subflow.
To provide the schema for coercion:
- Procedure
- On the flow details page, click the activity or trigger to open its configuration.
- Click any of the following tabs that you want to configure:
- Input: To configure a parameter in the activity input
- Output: To configure the schema for the activity output
- Map from Flow Outputs: To configure the trigger reply
- To configure a schema:
- For a parameter in activity input, hover your mouse cursor over the parameter name for which you want to configure the schema under Activity inputs.
- For the Activity output, hover your mouse cursor over the parameter name for which you want to configure the schema.
- For a parameter in the trigger reply, hover your mouse cursor over the parameter name.
Click the ellipsis icon (
) that is displayed next to it. Clear mappings and Coerce with schema options are displayed.
- Click the
Coerce with schema option.
Note: The Coerce with schema icon is displayed against the parameter name for only those parameters that do not have a schema defined on the Input Settings tab (or a schema cannot be defined because the Activity does not have an Input Settings tab, for example, the OSS-marked activities) and whose data type is one of the following: array, param, object, or any.
- Enter the schema for the parameter or activity output and click
Apply. The mapper validates that the data type of the schema you entered matches the data type of the parameter being coerced. If the data types do not match,
Apply remains disabled and you see an error.
For activity input and trigger reply, the schema you enter displays in a tree format under the parameter name in the mapper.
- For the activity output, the schema is displayed in a tree format on the Output tab of the activity. Available data displays the output of the preceding activities.
- Click Save to persist the schema into the database or Discard to discard the schema. Now you can map the child elements within the parameter. In the case of the activity Output tab, the output tree does not display in the current activity but is displayed in the mapper for subsequent activities only. Once persisted in the database, these schema trees get displayed in the Available data area of the mapper for subsequent activities. This allows you to map to them in subsequent activities.