Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

By the end of this chapter you will understand what a Calculate action is and how to use them, and you will have created three Calculate Actionflows in your application.

What is a Calculate Action?

The  Calculate action manipulates and processes data. Calculate nodes have their own attributes, which can reference incoming data via expressions, using one or more of the 135+ Functions available in PhixFlow.

Creating Calculate Actions

  1. Click and drag the  Calculate icon from the toolbar onto the canvas
  2. Enter a name for the Calculate action, then select Create Action
  3. In the Calculate Action  Properties on the right, click the  icon in the Output Attributes section to add new attributes

Example Uses

Calculate Actions can be used for:

  • inserting static text strings, e.g. inserting a new record into a grid containing the string "new"
  • performing Functions, e.g. adding debug messages to the System Console
  • performing lookups, e.g. counting records in a grid

Worked Examples

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

If you are completing this chapter as part of the Actionflow course and using a training instance, this data has already been pre-loaded into the Actionflow Application.

Use a Calculate Action to Add Static Text

Earlier in this course we created an Actionflow that opens a blank input form for adding new courses to the School Courses grid. In this example we will enhance that Actionflow by adding the static text "New Course" to the blank input form.

  1. Open the Course Management screen where the Actionflow will be initiated from
  2. Right-click on the  button on the School Courses grid and choose  Display Actionflow
  3. Click and drag the  Calculate icon from the toolbar onto the canvas
  4. Enter a name for the Calculate Action:
    1. Name: Course Header
    2. Select Create Action 
  5. The  Properties tab for the Calculate Action will open on the right
    1. If the  Properties tab is not open, click the Calculate Action node on the canvas 
  6. In the Output Attributes section, click the  icon
  7. Enter the following details for the new Output Attribute:
    1. Name: NewCourse
    2. Type: choose String
    3. Expression: 

      "Create New Course"
    4. Then  Apply and Close
  8. Drag and drop the Course Header Calculate Action onto the connector between the input node and the Open Course Form Action
  9. Right-click on the connector between the calculate node and the open screen node and choose Open Mappings
  10. On the Mappings window, drag the NewCourse attribute onto the Heading attribute to create the mapping
  11. Press Save
  12. Close the Actionflow to return to the Course Management screen
  13.  Lock the screen and press the  button to see the Actionflow in action
    1. We can see that the Actionflow is working because it displays the string, New Course in place of the original heading on the input form 

Use a Calculate Action to Perform a Function (Optional)

In this example, we will configure a button to run an Actionflow that performs a function. The results of the function will populate a dynamic text field.

Setup the Input and Calculate Action

  1. On the Course Management screen open the Layers and expand the area, Screen Header
  2. Expand the area, Right, and you will see two components - a button and a dynamic text field
  3. Click on the button, Button Date, in the Layers to highlight it on the screen
  4. Right-click on the button on the screen and choose  Add Actionflow
  5. Enter a name for the Actionflow,
    1. Name: Populate Date Field
    2. Select Confirm
  6. Select Click to Connect and for the input, choose the   On Click Action Event, then select Connect Input
  7. Click and drag the  Calculate icon from the toolbar onto the canvas
  8. Enter a name for the Calculate Action:
    1. Name: Get Date
    2. Select Create Action 
  9. The  Properties tab for the Calculate Action will open on the right
  10. In the Output Attributes section, click the  icon
  11. Enter the following details for the new Output Attribute:
    1. Name: TodayDate
    2. Type: choose String
    3. Expression: 

      now()
    4. Then  Apply and Close
  12. Click and drag the input onto the Get Date Calculate Action

Setup the Output and Write Back to the Screen

  1. In the Connections panel on the left, click  Add to create a new connection point
  2. Enter the following details for the new connection point:
    1. Name: out
    2. Type: choose Output
    3. Select Create Connection Point
  3. Select Click to Connect and for the output, choose the  Form datasource, then select Connect Output
  4. Close the Mappings window that automatically opens
  5. Hover over the Calculate Action node and select out
  6. A red arrow will appear - click on the output node under Connections
  7. On the Mappings window, drag the attribute, TodayDate, from the left (Calculate Action) to the right (output connection point) to create an attribute on the output
  8. Then select Save
  9. Under Connections, right-click on the connector, out, and choose Configure Mappings
  10. Drag the TodayDate attribute from the left (output connection point) and drop it onto the DateField target parameter on the right (Course Management screen)
  11. Then Save
  12. Close the Actionflow to return to the Course Management screen
  13.  Lock the screen and press the Button Date on the screen to see the Actionflow in action
    1. We can see that the Actionflow is working because it displays today's date in the format DD/MM/YY in the DateField dynamic text field

Use a Calculate Action to Perform a Function 

Earlier in this course we created an Actionflow that saves either new course data or edits to existing course data from the Course Form to the School Courses grid. In this example we will enhance that Actionflow by inserting a Calculate Action that will modify the data before it is saved. 

Setup the Input and Calculate Action

  1. On the Course Management screen open the La


  • No labels