What is a Calculate Action?
The Insert excerpt |
---|
| _action_calculate |
---|
| _action_calculate |
---|
nopanel | true |
---|
|
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
- Click and drag the
Insert excerpt |
---|
| _action_calculate |
---|
| _action_calculate |
---|
nopanel | true |
---|
|
icon from the toolbar onto the canvas - Enter a name for the Calculate action, then select Create Action
- In the Calculate Action
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
on the right, click the Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
icon in the Output Attributes section to add new attributes
HTML Comment |
---|
|
Insert excerpt |
---|
| Calculate Node Properties |
---|
| Calculate Node Properties |
---|
nopanel | true |
---|
|
|
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). |
Example Uses
Calculate Actions can be used for:
- inserting Inserting static text strings, e.g. when inserting a new record into a grid containing the string "new"performing set a value of "New" in a status field
- Calculating values using Functions, e.g. adding debug messages to the System Consoleperforming lookupsCalculating 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).
In this example, we are using:
- A Course Management screen containing a grid of the School Courses data - this screen was created using the Tile with Buttons template
- A Course Form screen containing form fields and associated with School Courses data by a background filter - this screen was created using the Edit Form template
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 Foundation Application. For this example, we'll be working on buttons on the Course Management screen and the Course Form screen. |
Example 1: 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 We want to add a message, "Create New Course", to the Course Form header that shows only when a new course is being created. To do this, we will add a Calculate Action to the Open Screen Actionflow for adding a new course.
Image Added
- On the screen where the Actionflow will be initiated fromRight, Course Management, right-click on the button on the School Courses grid and choose
Insert excerpt |
---|
| _actionflow_display |
---|
| _actionflow_display |
---|
nopanel | true |
---|
|
- If there is no Actionflow to display, see 1.07 Open Screen Action Configuration
- Click and drag the
Insert excerpt |
---|
| _action_calculate |
---|
| _action_calculate |
---|
nopanel | true |
---|
|
icon from the toolbar onto the canvas - Enter a name for the Calculate Action:
- Name:
Course Header
- Select Create Action
- The
Insert excerpt |
---|
| _property_tabs |
---|
| _property_tabs |
---|
nopanel | true |
---|
|
for the Calculate Action will open on the right- If the
Insert excerpt |
---|
| _property_tabs |
---|
| _property_tabs |
---|
nopanel | true |
---|
|
is not open, click the Calculate Action node on the canvas
- In the Output Attributes section, click the
Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
icon - 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 |
---|
|
- 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 calculate node and the open screen node and choose Open Mappingsthe 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 Header1Dynamic attribute to create the mapping
- Press Save
- Image RemovedImage Added
- Close the Actionflow to return to the Course Management screen
- the screen and press the button to see the Actionflow in action
- We can see that the Actionflow is working because it displays the string, Create New Course, in place of the original heading on the input form Course Form
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.
On the Course Management screen open the Layers and expand the area, Screen HeaderExpand the area, Right, and you will see two components - a button and a dynamic text fieldClick on the button, Button Date, in the Layers to highlight it on the screenRight-click on the button on the screen and choose Insert excerpt |
---|
_actionflow_add | _actionflow_add | nopanel | true |
Enter a name for the Actionflow,- Name:
Populate Date Field
- Select Confirm
Select Click to Connect and for the input, choose the add a Calculate Action that performs the function, toUpper, to a Save Actionflow. This function will format the course name on the Course Management screen into upper case, when the course is added/edited.
Image Added
- On the Course Management screen, click the Image Added or Image Added button to open the Course Form
- Right-click on the Image Added button and select
Insert excerpt |
---|
| _actionflow_on_clickdisplay |
---|
| _actionflow_on_clickdisplay |
---|
nopanel | true |
---|
|
Action Event, then select Connect Input - Click and drag the
Insert excerpt |
---|
| _action_calculate |
---|
| _action_calculate |
---|
nopanel | true |
---|
|
icon from the toolbar onto the canvas - Enter a name for the Calculate Action:
- Name:
Get Date
UppercaseName
- Select Create Action
The - Action
- Right-click on the input connection point under Connections and choose
Insert excerpt |
---|
| _propertymappings_tabsconfigure |
---|
| _propertymappings_tabsconfigure |
---|
nopanel | true |
---|
|
for the Calculate Action will open on the rightIn the Output Attributes section, click - 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 the
Insert excerpt |
---|
| _save_icon |
---|
| _save_icon |
---|
nopanel | true |
---|
|
SaveCourse node and drop it when the Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
icon appearsEnter the following details for the new Output Attribute: - Name:
TodayDate
- Type: choose
String
Expression:
Then Right-click on the in connector between the node and the Insert excerpt |
---|
| _actionflow_calculate |
---|
| _actionflow_calculate |
---|
nopanel | true |
---|
|
and select finishfinish- Click and drag the input onto the Get Date Calculate Action
Setup the Output and Write Back to the Screen
- In the Connections panel on the left, click
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
Expand |
---|
|
Image Added |
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 the
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
|
Add to to create a new connection pointEnter the following details for the new connection pointattribute:- Name:
out
UpperName
- Type: choose
Output
- Select Create Connection Point
Select Click to Connect and for the output, choose - String
Expression:
Code Block |
---|
|
toUpper(in.Name) |
Click
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
- Right-click on the in connector between the formform
actionflow_calculate | nopanel | true |
---|
|
datasource, then select Connect Output - Close the Mappings window that automatically opens
- Hover over the Calculate Action node and select out
- A red arrow will appear - click on the output node under Connections action node and the
Insert excerpt |
---|
| _action_save |
---|
| _action_save |
---|
nopanel | true |
---|
|
action node, and select Insert excerpt |
---|
| _open_mappings |
---|
| _open_mappings |
---|
nopanel | true |
---|
|
- On the Mappings window, drag the attribute, TodayDate UpperName, from the left ( Calculate Action (left) to the right (output connection point) to create an onto the Name attribute on the output
- Then select Save
- Under Connections, right-click on the connector, out, and choose Configure Mappings
- Drag the TodayDate attribute from the left (output connection point) and drop it onto the DateField target parameter on the right (Course Management screen)
- Then SaveSave Action (right)
Press Save
Expand |
---|
|
Image Added |
- Close the Actionflow to return to the Course ManagementForm
- Ensure the screen is the screen and press the Button Date on the screen ed, then add or edit the course details and press the Image Added button to see the Actionflow in actionOn the Course Management screen open the La
- We You 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
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.
- the Name for the course you just added/edited is now in capital letters on the Course Management screen
Image Modified