What is a Converge Action?
The Converge action is used to combine two or more paths together within an Actionflow, passing through attributes that are common to all incoming paths. It does not merge any records.
Converge actions are useful where data has been split to be processed separately but then needs to be brought back together for an action that only accepts one input, e.g. a Save action.
Creating Converge Actions
- Click and drag the Converge icon from the toolbar onto the canvas
- Enter a name for the Converge action, then select Create Action
- In the Converge Action Properties on the right, click the icon in the Output Attributes section to add new attributes, if required
- Connect to the Converge action by hovering over each input action node and selecting out, then create a new input connection point on the Converge action
Output Attributes
The Converge Node will only pass through attributes that are common to all paths, therefore, use Output Attributes to converge attributes to a common name. Once created, map to the Output Attributes using the attributes from incoming paths.
To check if a record in an Actionflow has a value mapped to an Output Attribute in a Converge Node, use the ifUnavailable function in a Calculate action. See 1.11 Calculate Action Configuration.
For example, if there are three paths being passed into a Converge Node, and one of the paths does not have an attribute mapped to an output attribute, trying to reference that output attribute later in the Actionflow will throw an error on a record where there was no attribute mapped. The ifUnavailable function can be used to capture and handle this scenario.
Worked Example
Here's a worked example using the Shop Data (available from the Learning Centre).
In this example, we are using:
- A Customer Form screen containing blank input fields, set up to create a new customer - this screen was created using the Edit Form template
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Intermediate Application. For this example, we'll be working on the Save button on the Customer Form screen.
If you have completed 2.07 Embedded Actionflows prior to starting this worked example, ensure the Actionflow on the Save button on the Customer Form screen is Removed. Then re-add a simple Save Action using the Form Actions wizard.
Process New Customers Differently Depending on Mailing List Subscription
For this example, we'll create an Actionflow that splits our data depending on if a new customer has joined a mailing list, allowing the customers who have joined to be processed separately. The new customer data for both the customer who have and haven't joined the mailing list is them converged back together so that the customer record can be updated with the current date and time (for the LastUpdated attribute), and the new customer record saved back to the table.
We recommend that you have prior knowledge of Gateway actions and Email actions or have completed 2.03 Gateway Action Configuration and 2.05 Email Action Configuration.
Initial Setup
- Open the Customer Form and Unlock the screen
- Open the Actionflow on the Save button
- Click on the input connection point (under Connections) and map in the following attributes into the Actionflow:
- first_name
- LastUpdated
- mailingList
- Disconnect the input from the Save action on the canvas
Gateway Setup
- Create a Gateway action
- Name:
Mailing List
- Name:
- Drag the input node onto the Gateway action
- Map the mailingList attribute into the Gateway action on the in connector
- Click on the Gateway node to open its Properties
- Toggle on, Exclusive
- Modify the existing Rule and Add another Rule, as detailed below:
- Name: EmailMe
in.mailingList == true
- Name: DontEmailMe
in.mailingList != true
- Apply the gateway settings
Hover over the Gateway action to show the 2 output connections
- Click on DontEmailMe, then click on any white space on the canvas and use the popup menu to create a new Converge action
- Name:
CombineData
- Map across the customerID attribute
- Name:
- Repeat with the EmailMe output connection and create a new Embedded Actionflow
- Name:
SendWelcomeEmail
- Name:
- Click on DontEmailMe, then click on any white space on the canvas and use the popup menu to create a new Converge action
Embedded Actionflow Setup
- Click on the EmailMe connector and map in the attributes that will be needed to send a welcome email to the new customer:
- customerID
- first_name
- Hover over the Embedded Actionflow node and choose out to connect the SendWelcomeEmail Embedded Actionflow node to the CombineData Converge action
- After clicking on the Converge node, choose Add Input and name the connection
- Map across the customerID attribute
- Right-click on the SendWelcomeEmail Embedded Actionflow and choose Display
- On the SendWelcomeEmail Actionflow, create a new Email action
- Name:
WelcomeEmail
- Name:
- Connect the input node to the Email action
- Map the same attributes as above into the Email action
- Click on the Email Action to open its Properties and Pin the tab
- For the From field, we need to use the email address specified as the login email in your Outbound Emailer; to find this, in the Full Repository, expand Email Accounts
- Double-click on Outbound emailer and copy the login email
- Paste this into the From field on your pinned Email properties, and enter the following:
To:
${in.email}
Subject:
Welcome ${in.first_name}!
- is HTML: Toggle on
Message:
Hello ${in.first_name} and welcome to the PhixFlow Shop Newsletter. Thank you for joining our mailing list. We'll send you news and offers every week!
- Leave all other fields blank
- Apply and Close
- Hover over the Email action and select out
Click on the output node under Connections to map the data back to the Save Actionflow
Converge & Calculate Setup
- Click back into the Actionflow for the Save button
- From the CombineData Converge action, click out and create a Calculate action
- Name:
SetLastUpdated
- Map the attribute, LastUpdated, into the Calculate action
- Name:
- On the Calculate action, add an Output Attribute:
- Name:
SetLastUpdated
- Type:
Datetime
Expression:
now()
- Name:
Save Setup
- Connect the Calculate action to the Save action
- Map across the customerID attribute from the Converge action to the Save
- Map across the SetLastUpdated attribute from the Calculate action to the LastUpdated attribute on the Save
Testing
To test the Actionflow we need to add two new customers.
- Close and reopen the Customer Form
- Lock the screen and enter the details for a new customer, ensuring:
- for the Email Address field, you enter your own email address
- for the "Would the customer like to join the mailing list?" field, you toggle the switch on
- After pressing Save, you should see the customer is saved on the Customer screen and you should receive an email
- Repeat these steps to create another customer, using your email address but this time, toggle off "Would the customer like to join the mailing list?"
- Check that the customer is still created and saved on the Customer screen but that no email is received