Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
What is a Calculate Action?
The
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. Insert excerpt _action_calculate _action_calculate nopanel true
Creating Calculate Actions
- Click and drag the
icon from the toolbar onto the canvasInsert excerpt _action_calculate _action_calculate nopanel true - Enter a name for the Calculate action, then select Create Action
- In the Calculate Action
on the right, click theInsert excerpt _property_settings _property_settings nopanel true
icon in the Output Attributes section to add new attributesInsert excerpt _add_icon _add_icon nopanel true
HTML Comment | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
|
Tip |
---|
Calculate actions and their connection points, can have an attribute type of Structured Data. Use this if you need the Actionflow to pass a list (an array of values), such as a list of identifiers. |
Example Uses
Calculate Actions can be used for:
- Inserting static text strings, e.g. when inserting a new record set a value of "New" in a status field
- Calculating values using Functions, e.g. Calculating the amount of VAT on a customer invoice
- Performing lookups against a View action node or lookup connection point, e.g. counting records in a grid or retrieving details of all students on a course
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. |
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.
- Open the Course Management screen where the Actionflow will be initiated from
- Right-click on the button on the School Courses grid and choose
Insert excerpt _actionflow_display _actionflow_display nopanel true - Click and drag the
icon from the toolbar onto the canvasInsert excerpt _action_calculate _action_calculate nopanel true - Enter a name for the Calculate Action:
- Name:
Course Header
- Select Create Action
- Name:
- The
for the Calculate Action will open on the rightInsert excerpt _property_tabs _property_tabs nopanel true - If the
is not open, click the Calculate Action node on the canvasInsert excerpt _property_tabs _property_tabs nopanel true
- If the
- In the Output Attributes section, click the
iconInsert excerpt _add_icon _add_icon nopanel true - Enter the following details for the new Output Attribute:
- Name:
NewCourse
- Type: choose
String
Expression:
Code Block "Create New Course"
- Then
Insert excerpt _finish _finish nopanel true
- Name:
- Drag and drop the Course Header Calculate Action onto the connector between the input node and the Open Course Form Action
- Right-click on the connector between the Course Header Calculate Action and the Open Course Form Open Screen Action and choose
Insert excerpt _open_mappings _open_mappings nopanel true - On the Mappings window, drag the NewCourse attribute onto the Heading attribute to create the mapping
- Press Save
- Close the Actionflow to return to the Course Management screen
the screen and press the button to see the Actionflow in actionInsert excerpt _lock _lock nopanel true - 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
In this example, we will modify the Save Actionflow we created in an earlier chapter to perform the function, toUpper, which will format the course name into upper case. This example uses data for the input.
Setup the Input
- On the Course Management screen click the or button to open the Course Form
- Right-click on the button and select
Insert excerpt _actionflow_display _actionflow_display nopanel true - Click and drag the
icon from the toolbar onto the canvasInsert excerpt _action_calculate _action_calculate nopanel true - Enter a name for the Calculate Action:
- Name:
UppercaseName
- Select Create Action
- Name:
- Right-click on the input connection point under Connections and choose
Insert excerpt _mappings_configure _mappings_configure nopanel true - On the Mappings window, drag the attribute, Name, from the left (Course Form) into the Drag and Drop space on the right (input connection point)
- Select Save
- On the canvas, drag the UppercaseName Calculate Action node onto the in connector between the
node and theInsert excerpt _input _input nopanel true
SaveCourse node and drop it when theInsert excerpt _save_icon _save_icon nopanel true
icon appearsInsert excerpt _add_icon _add_icon nopanel true - Right-click on the in connector between the
node and theInsert excerpt _input _input nopanel true
and selectInsert excerpt _actionflow_calculate _actionflow_calculate nopanel true Insert excerpt _open_mappings _open_mappings nopanel true - On the Mappings window, drag the Name attribute from the left to the right (calculate action)
Tip We only need to map the Name attribute here because it is used within the Calculate Action.
The CourseID attribute will pass through the Calculate Action and can be used later on in the Actionflow.
- Select Save
Setup the Calculate Action
- Select the Calculate Action, UppercaseName, to open its
Insert excerpt _property_settings _property_settings nopanel true - In the Output Attributes section, click
to create a new attribute:Insert excerpt _addIcon _addIcon nopanel true - Name:
UpperName
- Type: choose String
Expression:
Code Block toUpper(in.Name)
- Name:
- Right-click on the in connector between the
node and theInsert excerpt _actionflow_calculate _actionflow_calculate nopanel true
and selectInsert excerpt _action_save _action_save nopanel true Insert excerpt _open_mappings _open_mappings nopanel true - On the Mappings window, drag the attribute, UpperName, from the Calculate Action (left) onto the Name attribute on the Save Action (right)
- Press Save
- Close the Actionflow to return to the Course Form
- Ensure the screen is
ed, then add or edit the course details and press the button to see the Actionflow in actionInsert excerpt _lock _lock nopanel true - You can see that the Actionflow is working because the Name for the course you just added/edited is now in capital letters on the School Courses grid