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 14 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 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

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.

We want to be able to filter the records that can be seen in our 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

  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. : This will reset the grid to show all records
    2. : This will show only records where the department name is Mathematics
    3. : This will show only records where the department name is English

Reset Filter

  1. Right-click on the  button and choose  Add Actionflow
  2. Enter a name for the Actionflow:
    1. Name: All Filter
  3. Connect the filter button by selecting Click to Connect
    1. For the input, choose the On Click Action Event, then select Connect Input
  4. Click and drag the  Calculate icon from the toolbar onto the canvas
  5. Enter a name for the Calculate action:
    1. Name: Reset Filter
    2. Select Create Action
  6. Click and drag the  icon onto the  Calculate Reset Filter node to connect the input to the action
  7. Click on the Reset Filter node to open its  Properties tab on the right
  8. In the Output Attributes section, click the  icon
  9. Enter the following details for the new Output Attribute:
    1. Name: pfDept
    2. Type: choose String
    3. Expression: 

      "All"
    4. Then  Apply and Close
  10. Under Connections, click  Add
  11. In the Add Connection Point window, enter:
    1. Name: Out
    2. Type: choose Output
    3. Select Create Connection Point
  12. Click on Click to Connect
  13. In the Connect Output window, choose the Course Management form and select Connect Output
  14. Close the Mappings window that opens
  15. Hover over the Reset Filter calculate node on the canvas and select out
  16. A red arrow will attach to your mouse, click on the  icon under Connections
  17. 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
  18. Right-click the Out wire, under Connections, and choose  Configure Mappings
  19. The Mappings window will open:
    1. Select Map by Name
    2. Press Save
  20. Close the Actionflow to return to the Course Management screen
  21.  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, All, in the pfDept String field and all records display in the grid

Did 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  button, with some guidance below.

  1. Right-click on the  button and choose  Add Actionflow
  2. Enter a name for the Actionflow:
    1. Name: Maths Filter
  3. 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:

      "Mathematics"

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

  4. Close the Actionflow to return to the Course Management screen
  5. 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, 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  filter button.

 Feeling stuck?

Repeat the same steps as you did to set up the All and Maths filters, but swap in "English" instead.



  • No labels