Working with Output Attributes in Automations Workflows
Messages pass along the components of Automations workflows, from triggers to actions to external actions, in the form of JSON-formatted key-value pairs, or attributes in FME. These attributes represent various properties that are derived from the components of the workflow, and form the content of the message. Each attribute that is output by a component can be sent downstream to the next component, and ultimately output by the workflow to a receiving application.
You can work with the output attributes of workflow messages in the following ways:
- View attributes, disable and enable attributes, and create custom attributes.
- Create global automation parameters.
- Work with nesting levels in attributes.
- Filter for the presence of a string in an attribute value.
Viewing Attributes, Disabling/Enabling Attributes, and Creating Custom Attributes
As you create an Automations workflow, you can control the attributes that are sent to downstream components in a workflow, and that are ultimately included in the final message output. In the Details pane of a trigger, action, or external action, select the Output Attributes tab. Here, you can:
- View the attributes that the component generates. Where applicable, the component generates separate sets of output attributes for the success (✔) and failure (x) ports of a component. Run a Workspace actions that reference workspaces configured with FME Flow Automations writers also generate output attributes for each writer feature type. For more information, see Routing Data from Workspaces.
- Disable or enable attributes. By default, all applicable attributes are enabled in the outgoing message as it passes downstream.
- Create custom attributes with user-defined names, and prefixed with the user. tag. You can assign the value of a custom attribute from an existing attribute, a parameter from the Deployment Parameter Store, or a constant.
The primary benefit of disabling attributes or creating custom attributes is to prevent them from being overwritten, where desired. The values of JSON objects with the same attribute strings are overwritten as they pass through a workflow. For example, consider a workflow that contains two Run Workspace actions in sequence. Both actions pass a job.timeStarted attribute, but the value that attribute produces in the first action is overwritten by the second action. If you want to preserve only the job.timeStarted value of the first workspace, you can disable the job.timeStarted attribute in the configuration of the second action, and preserve it in the first.
But what if you wanted to preserve both job.timeStarted values? In this case, you can create a custom attribute in both workspaces, give them each unique names, and base their values on job.timeStarted. Optionally, you can also disable job.timeStarted in both workspaces.
You can use custom attributes anywhere in a workflow that allows you to specify an attribute for a parameter value.
Creating Global Automation Parameters
You can create your own automation parameters, prefixed with the global. tag. Automation parameters allow you to reference a value in multiple components of a workflow without having to explicitly define it each time. You can use automation parameters anywhere in a workflow that allows you to specify an output attribute for a parameter value.
You can create automation parameters in the following ways:
- On the Automations toolbar, click the Automation Parameters Editor button.
- Dynamically, when specifying a parameter value in a workflow. From an applicable parameter drop-down list, select Add to Automation Parameters.
In the Automation Parameters Editor, click + to start a new Automation Parameter, enter a name (global.<your_name>), specify a Value, and click OK. You can specify a Value manually, or select one from the Deployment Parameter Store.
Working with Nesting Levels in Attributes
When an automation encounters messages with attributes that contain multiple levels of nesting, the automation parses the 0th, 1st, 2nd, and 3rd innermost levels of an attribute to resolve, or create, output attributes.
For example, consider a message attribute {route.apple} assigned value apple. The following message has zero nested attribute levels:
{
"{route.apple}"
}
This message resolves to the value apple as an output attribute.
The following message contains 0-4 nested attribute levels:
{
"{route.{route.{route.{route.{route.apple}}}}}"
}
This message resolves to the value route.apple as an output attribute because the outermost, or 4th, nested level is unresolved.
Filtering on an Output Attribute
You can use the Filter Messages action to test for the presence of a string in an output attribute, and route messages in your workflow accordingly. For example, if the email.subject attribute from an Email - SMTP trigger contains a specific string, you might choose to route the message differently from other emails that do not contain that string.