2.07 Embedded Actionflows

What is an Embedded Actionflow?

An action node or group of action nodes can be nested within an  Actionflow node that can be reused without reusing the entire Actionflow. For example, a Calculate Action that normalises an area code can be extracted from its original Actionflow and reused (embedded) within many other Actionflows using its  Actionflow node.                         

For reusing entire Actionflows, see 1.17 Instances and Reusability. For extracting or moving an action(s) to another Actionflow, see 2.06 Extracting and Moving Actions.

Embedding Actionflows

An action(s) can be embedded after using the  Extract to new Actionflow option,  see 2.06 Extracting and Moving Actions, or by opening the list of Actionflows in the  Repository and dragging one onto the canvas.

  1. Click the  Actionflow option in the toolbar
  2. Drag and drop an  Actionflow from the Repository onto the canvas
  3. An embedded  Actionflow node is created
    1. If any changes are required to the functionality within the embedded Actionflow, right-click on the embedded node and choose  Display

Embedding Compatibility

  • Actionflows containing  Phases,  Start Phase actions, and confirmation screens cannot be embedded
  • When editing an Actionflow that has been embedded,  Phases cannot be created
  • An Actionflow in an application cannot be embedded in a package

Worked Example

Here's a worked example using the Retail Data (available from the Learning Centre).

In this example, we are using:  

  • Staff Form screen containing blank input fields, set up to create a new staff member  - 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 Staff Form screen.

Prerequisites 

For this example, we'll embed an extracted Actionflow. If you have not completed 2.06 Extracting and Moving Actions, expand the section below and follow the steps to create an extracted Actionflow.

.

 Create an Extracted Actionflow

Extract Proper Case Calculate Action

In this example, we'll modify the Actionflow on the Save button for when a customer is created. We'll configure this Actionflow to convert the string entered for the First Name attribute to proper case, for example, if the user enters "JOHN" or "john", this action will convert this string to "John". 

We'll then extract this Actionflow for use elsewhere in our application.

Create Proper Case Calculate Action

  1. Open the Actionflow on the Save button on the Customer Form
  2. Add a  Calculate Action
    1. This will be used to convert the text to proper case 
  3. Drag the Calculate Action onto the connector between the input and Save action
  4. Click on the input connector under Connections and map in the first_name attribute
  5. Map these two attributes into the Calculate action
  6. On the Calculate action, create a new Output Attribute that will convert text to proper case, using the following Expression
    Expression
    do(
    
        /* put the name into lowercase, e.g. "john" */
        toLower(in.first_name), " ", 
            
        /* put the first letter into upper case, e.g. "J" */
        $firstLetter = toUpper(substring(in.first_name, 1,1)), 
                
        /* put the name from the 2nd letter onwards into lower case, e.g. "ohn" */
         $remainingLetters = toLower(substring(in.first_name, 2)), 
                    
        /* create a new proper case name using the upper case first letter and lower case remaining letters, e.g. "J" + "ohn" = "John" */
        $newName = $firstLetter + $remainingLetters
    )
  7. Click on the connector between the Calculate action and the Save action

  8. Map across the new Output Attribute onto the first_name attribute

     Checkpoint

  9. Close the Actionflow and Customer Form
  10. Reopen the Customer Form and enter a First Name in upper or lower case, then press Save to test the Actionflow
  11. Open the Shop Staff screen to see the new customer record with a correctly formatted first name

Extract Proper Case Calculate Action

  1. Re-open the Actionflow
  2. Right-click on the Calculate Action and choose  Extract to new Actionflow
  3. Name the Actionflow: Proper Case
    1. Ensure the attribute customerID is removed from the out connector on the canvas of the Proper Case Actionflow so that the Actionflow can be reused elsewhere in your application

.

Embed Proper Case Actionflow

In this example, we'll embed an extracted action node that converts a First Name string to proper case. We'll embed this within the Save action on the Staff Form.

Embed Extracted Action in Actionflow

  1. Open the Actionflow on the Save button on the Staff Form
  2. Click  Actionflow in the toolbar and drag the Proper Case Actionflow from the  Repository onto the canvas
  3. Click and drag  Actionflow node onto the connector between the  input and  Gateway action and drop it when the  icon appears
  4. Choose the out_ProperCase connection point from the Select Connection Point pop up
  5. Click on the connector between the input and embedded node and map across the attribute first_name
  6. Click on both connectors between the  Gateway node and  Save actions
    1. On both connectors, map across the ProperCase attribute from the embedded  Actionflow node to the first_name attribute on the table

       Checkpoint

Testing

  1. To test the Actionflow, open the Shop Staff screen
  2. Select an existing staff member from the grid and press Edit
  3. Change their first name to be in capitals and click Save
  4. You should see on the Staff grid that their first name has saved in proper case