Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
_Banners
_Banners
nameactionflow
nopaneltrue

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 

Insert excerpt
_action_calculate
_action_calculate
nopaneltrue
 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 
    Insert excerpt
    _action_calculate
    _action_calculate
    nopaneltrue
     icon from the toolbar onto the canvas
  2. Enter a name for the Calculate action, then select Create Action
  3. In the Calculate Action 
    Insert excerpt
    _property_settings
    _property_settings
    nopaneltrue
     on the right, click the 
    Insert excerpt
    _add_icon
    _add_icon
    nopaneltrue
     icon in the Output Attributes section to add new attributes
HTML Comment
hiddentrue

Insert excerpt
Calculate Node Properties
Calculate Node Properties
nopaneltrue

Example Uses

Calculate Action

  • insert Static text - "new" - needs a simple example
  • have a example with a function
  • example Use cases: insert static text (include worked example), perform a calculate (include worked example), performing lookups
Worked Example

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).

Tip

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.

We want to be able to filter the records that can be seen in our

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. To do this, we will create three Calculate Actionflows. Each Actionflow will populate a string field with a string of text. That text will then be interpreted by a background filter to see if it matches any records for the specified attributes, and will filter the grid accordingly.

Calculate Actions to Initiate Filters

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. The Filters panel on the left of the screen contains a number of buttons which we will set up so when they are pressed, the School Courses grid is filtered:
    1. Image Removed: This will reset the grid to show all records
    2. Image Removed: This will show only records where the department name is Mathematics
    3. Image Removed: This will show only records where the department name is English

Reset Filter

  1. Right-click on the Image RemovedImage Added button on the School Courses grid and choose 
    Insert excerpt
    _actionflow_adddisplay
    _actionflow_adddisplay
    nopaneltrue
  2. Enter a name for the Actionflow:
    1. Name: All Filter
  3. Connect the filter button by selecting Click to ConnectFor the input, choose the On Click Action Event, then select Connect Input
  4. Click and drag the 
    Insert excerpt
    _action_calculate
    _action_calculate
    nopaneltrue
     icon from the toolbar onto the canvas
  5. Enter a name for the Calculate actionAction:
    1. Name: Reset Filter Course Header
    2. Select Create Action
    Click and drag the 
    1. Action 
  6. The 
    Insert excerpt
    _driving_interface_connection_pointproperty_tabs
    _driving_interface_connection_point
    nameicon
    property_tabs
    nopaneltrue
     icon onto the  Insert excerpt_action_calculate_action_calculatenopaneltrue Reset Filter node to connect the input to the actionClick on the Reset Filter node to open its  for the Calculate Action will open on the right
    1. If the 
      Insert excerpt
      _property_tabs
      _property_tabs
      nopaneltrue
     on the right
    1. is not open, click the Calculate Action node on the canvas 
  7. In the Output Attributes section, click the 
    Insert excerpt
    _add_icon
    _add_icon
    nopaneltrue
     icon
  8. Enter the following details for the new Output Attribute:
    1. Name: pfDept NewCourse
    2. Type: choose String
    3. Expression: 

      Code Block
      "AllCreate New Course"


    4. Then 
      Insert excerpt
      _finish
      _finish
      nopaneltrue
    Under Connections, click  Insert excerpt_addIcon_addIconnopaneltrue Add
  9. In the Add Connection Point window, enter:
    1. Name: Out
    2. Type: choose Output
    3. Select Create Connection Point
  10. Click on Click to Connect
  11. In the Connect Output window, choose the Course Management form and select Connect Output
  12. Close the Mappings window that opens
  13. Hover over the Reset Filter calculate node on the canvas and select out
  14. A red arrow will attach to your mouse, click on the  Insert excerpt_output_outputnameiconnopaneltrue icon under Connections
  15. The Mappings window will open:
    1. Drag across the Output Attribute, pfDept, into the area on the right to create a corresponding attribute on the output connection point
    2. Press Save
  16. Right-click the Out wire, under Connections, and choose Insert excerpt_action_map_action_mapnopaneltrue
  17. The Mappings window will open:
    1. Select Map by Name
    2. Press Save
  18. Drag and drop the Course Header Calculate Action onto the connector between the input node and the Open Course Form Action
    1. Image Added
  19. Right-click on the connector between the calculate node and the open screen node and choose Open Mappings
  20. On the Mappings window, drag the NewCourse attribute onto the Heading attribute to create the mapping
  21. Press Save
    1. Image Added
  22. Close the Actionflow to return to the Course Management screen
  23. Insert excerpt
    _lock
    _lock
    nopaneltrue
     the screen and press the Image Removed button Image Added button to see the Actionflow in action
    1. We can see that the Actionflow is working because it displays the string, All, in the pfDept String field and all records display in the grid
Tip
titleDid you know?

There are also Background Filters working in tandem with the string field to filter the results in the grid.

The Actionflow we created above populates the string field, pfDept.

The Background Filters that have already been set up on the grid look inside the string field, then change the records you can see on the grid according to what it finds in the string field.

This important to know for debugging, as if the spelling of the string in the expression of the Output Attribute in the Actionflow does not match the string in the background filter, the filter button will not work.  

To see the setup of the Background Filters, click on the School Courses grid, then in the Properties tab on the right there is a Background Filters section. Double-click on the filters to open them and spend some time looking at these to understand how they work.

Maths Filter

Have a go at creating the Actionflow for the Image Removed button, with some guidance below.

    Right-click on the Image Removed button and choose  Insert excerpt_actionflow_add_actionflow_addnopaneltrue
  1. Enter a name for the Actionflow:
    1. Name: Maths Filter
  2. Repeat the same steps as with the All Filter, but make the following changes:
    1. Name the Calculate Action: Maths Filter
    2. When creating a new Output Attribute, the following expression should be used:

      Code Block
      "Mathematics"
      Tip
      titleWhy do we use "Mathematics" and not "Maths"?
      We use "Mathematics" because this is the spelling of the Department Name in our data (you can see this on the School Courses grid), therefore the Background Filter is looking to match up the text in the string field with the data name. Where it gets a match, it will filter the grid accordingly. If we use a different spelling or shortening, the filter will not work as expected.  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 
    Insert excerpt
    _actionflow_add
    _actionflow_add
    nopaneltrue
  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 
    Insert excerpt
    _actionflow_on_click
    _actionflow_on_click
    nopaneltrue
     Action Event, then select Connect Input
  7. Click and drag the 
    Insert excerpt
    _action_calculate
    _action_calculate
    nopaneltrue
     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 
    Insert excerpt
    _property_tabs
    _property_tabs
    nopaneltrue
     for the Calculate Action will open on the right
  10. In the Output Attributes section, click the 
    Insert excerpt
    _add_icon
    _add_icon
    nopaneltrue
     icon
  11. Enter the following details for the new Output Attribute:
    1. Name: TodayDate
    2. Type: choose String
    3. Expression: 

      Code Block
      now()


    4. Then 
      Insert excerpt
      _finish
      _finish
      nopaneltrue
  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
    Insert excerpt
    _addIcon
    _addIcon
    nopaneltrue
     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 
    Insert excerpt
    _form
    _form
    nopaneltrue
     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 screenLock the
  13. Insert excerpt
    _lock
    _lock
    nopaneltrue
     the screen and press the Image Removed button Button Date on the screen to see the Actionflow in action
    1. We can see that the Actionflow is working because it displays the string, Mathematics, in the pfDept String field and just the matching records display in the grid

English Filter

Use the knowledge you have acquired throughout this chapter to independently create the Actionflow for the Image Removed filter button.

Expand
titleFeeling stuck?
Repeat the same steps as you did to set up the All and Maths filters, but swap in "English" instead.
    1. 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