Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
What is a Lookup?
Lookups are denoted by a dotted double-ended connector transferring data into and out of a
Action, and are used to lookup and retrieve records in other recordsets. Lookup views require: Insert excerpt _action_view _action_view nopanel true
- Incoming Mappings: the attributes being passed into the View Action via the lookup connector
- Output Attributes: the attributes being used by View Action to filter results
- Outgoing Mappings: the attributes being passed out of the View Action via the lookup connector
Expand | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
|
Creating Lookups
- Hover over an action node, e.g. a Calculate Action, on the canvas and select
- Enter a name for the Lookup Connector
- Click onto a
action on the canvasInsert excerpt _action_view _action_view nopanel true - Alternatively, click onto any empty space on the canvas to create a new
ActionInsert excerpt _action_view _action_view nopanel true
Worked Example
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 - this screen was created using the Tile with Buttons template, and contains:
- A grid of the School Courses data
- A contacts card container of the School Students data
- An empty string field, StudentIDFromAttendees
Tip |
---|
If you are completing this chapter as part of the Actionflow course and using a training instance, the data and screens have already been pre-loaded into the Actionflow Foundation Application. For this example, we'll be working on the expandable tile on the Course Management screen. |
Lookup to Retrieve
DataWe will create an Actionflow containing aCourse Attendees
In this example, we want to see the students enrolled on each course. To do this, we will use the course data to lookup and retrieve the associated attendees data, then output the attendee data back to the screen where it can be used to filter the students data.
To do this it we will:
- Lookup using the Course ID, which is found on both the Course and Attendees tables
- Use the Course ID on the Attendees table to find the corresponding Student ID(s) of the student(s) attending that course
- Write those Student ID(s) back to the screen onto a string field
- Setup a background filter to only show students in a Students contacts card container that match the Student ID in the field
Screen Setup
your screen to expand the Students contacts card container on the right, shown by the tile with chevronInsert excerpt _lock _lock nopanel true
your screen and clickInsert excerpt _unlock _unlock nopanel true
in the toolbar to open the Serene Grey paletteInsert excerpt _palette _palette nopanel true - Expand Buttons - Secondary and add a custom button to the Tile - Footer area beneath the School Courses grid
- Name:
Enrolled Students
- Name:
- Using the
, hold down shift to move the button into the area, RightInsert excerpt _layers _layers nopanel true
Create Calculate Action and View Action
- Right-click on the Enrolled Students button and choose
Insert excerpt _actionflow_add _actionflow_add nopanel true - Enter a name for the Actionflow:
- Name:
Find Students
- Select Confirm
- Name:
- Select Click to Connect and for the input, choose the School Course
View Component, then select Connect InputInsert excerpt _grid _grid nopanel true - In the Mappings window that opens, drag the CourseID attribute from the left to the right
- Select Save
- Click and drag the
icon from the toolbar onto the canvasInsert excerpt _action_calculate _action_calculate nopanel true - In the Create Calculate Action window enter:
- Name:
FindStudents
Select Create Action
Note For the input data, the attributes pass through the Calculate action without being processed. For the output data, the Calculate action processes the data into an array.
- Name:
- Click and drag the
icon onto theInsert excerpt _driving_interface_connection_point _driving_interface_connection_point name icon nopanel true
action nodeInsert excerpt _action_calculate _action_calculate nopanel true - Right-click on the in connector and choose
Insert excerpt _open_mappings _open_mappings nopanel true - Drag the CourseID attribute on the left onto the Drag and Drop area on the right
- Select Save
- To look up to the Course Attendees table, we need to create a
ActionInsert excerpt _action_view _action_view nopanel true - Click and drag the
icon from the toolbar onto the canvasInsert excerpt _action_view _action_view nopanel true - In the Create View Action window enter:
- Name:
GetStudentID
- Primary Table: choose Course Attendees
Select Create Action
- Name:
Expand | ||
---|---|---|
| ||
Configure the Lookup on the View Action
- Hover over the
Action and selectInsert excerpt _action_calculate _action_calculate nopanel true - Enter a name for the Lookup Connector:
- Name:
lu
- Select Confirm
- When the red arrow shows, click on the
action on the canvasInsert excerpt _action_view _action_view nopanel true
- Name:
- Select the
action on the canvas to open itsInsert excerpt _action_view _action_view nopanel true Insert excerpt _property_settings _property_settings nopanel true - In the Output Attributes section, click on the
iconInsert excerpt _attributes_icon _attributes_icon nopanel true - In the Available Attributes window, drag StudentID into the Output Attributes section of the
Insert excerpt _property_settings _property_settings nopanel true - Click OK
- In the Available Attributes window, drag StudentID into the Output Attributes section of the
- Select the lu connector to map the incoming and outgoing data
- For the Incoming Mappings:
- Drag the CourseID attribute from the left (Calculate Action) into the Drag and Drop area on the right to create a corresponding attribute in the
actionInsert excerpt _action_view _action_view nopanel true - Select Next
- Drag the CourseID attribute from the left (Calculate Action) into the Drag and Drop area on the right to create a corresponding attribute in the
- For the Outgoing Mappings:
- Drag the StudentID attribute from the left (View Action) to the Drag and Drop area on the right to map a corresponding attribute back to the
actionInsert excerpt _action_calculate _action_calculate nopanel true - Right-click on the StudentID attribute you just created and select
Insert excerpt _edit _edit nopanel true - Rename the attribute:
StudentIDFound
- Click Confirm
- Drag the StudentID attribute from the left (View Action) to the Drag and Drop area on the right to map a corresponding attribute back to the
- We need to filter the data coming out of the lookup
- Click on the
action to open its PropertiesInsert excerpt _action_view _action_view nopanel true - In the Data Retrieval Options section, click the
icon next to FilterInsert excerpt _addIcon _addIcon nopanel true - Name:
ByCourseID
- Filter Details:
- Click abc to tell PhixFlow to interpret the field as an expression
the Filter tabInsert excerpt _finish _finish nopanel true
- Name:
the View Action tabInsert excerpt _save _save nopanel true
Expand | ||
---|---|---|
| ||
Configure the Calculate Action and Output
- Click on the
action on the canvas to open itsInsert excerpt _action_calculate _action_calculate nopanel true Insert excerpt _property_tabs _property_tabs nopanel true - In the Output Attributes section, click the
icon to create a new attribute:Insert excerpt _addIcon _addIcon nopanel true - Name:
CourseStudentIDs
- Type: Choose
Structured Data
- This will return the results as an array
Expression:
Code Block language js theme Emacs lu.StudentIDFound
Click
Insert excerpt _finish _finish nopanel true
- Name:
- Under Connections on the left, select
AddInsert excerpt _addIcon _addIcon nopanel true - Add an Output Connection Point:
- Name:
out
- Type: choose Output
- Click Create Connection Point
- Name:
- Select Click to Connect and choose the CourseManagement
, then Connect OutputInsert excerpt _form _form nopanel true - Close the Mappings window that opens
- Hover your mouse over the
action on the canvas and click outInsert excerpt _action_calculate _action_calculate nopanel true - When the red arrow shows, click on the
node under ConnectionsInsert excerpt _output _output name icon nopanel true - On the Mappings window, drag across the CourseStudentIDs output attribute from the Calculate action into the Drag and Drop area on the right to create a corresponding attribute in the output
- Click Save
- Click the out connection point, under Connections
- On the Mappings window, drag the CourseStudentIDs output attribute from the output to the string field, StudentIDFromAttendees
- Click Save
- The Actionflow is now built
Expand | ||
---|---|---|
| ||
Setup Background Filter
The Actionflow will populate the string field, StudentIDFromAttendees, but the values in this field need to be linked to the Students contact cards using a background filter in order to only see the students for the selected course only.
- Return to the Course Management screen
Click on the Students contact card container to open the Card Component
Insert excerpt _property_settings _property_settings nopanel true - Ensure you click on the white space underneath the top contact card to open the Card Component
On the
, in the Background Filter Rules section, clickInsert excerpt _property_tabs _property_tabs nopanel true Insert excerpt _addIcon _addIcon nopanel true - Enter the Rule Expression:
true
- Create a new filter by pressing
next to Filter:Insert excerpt _addIcon _addIcon nopanel true - Name:
ByStudentID
- Filter Details:
- Click
on both the Filter and Filter RuleInsert excerpt _finish _finish nopanel true Insert excerpt _property_settings _property_settings nopanel true
- Name:
the screen and press the Enrolled Students button to see the Actionflow workingInsert excerpt _lock _lock nopanel true
Tip | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Once you have verified the Actionflow is working, the StudentIDFromAttendees string field can be hidden in the
|