Lookup Configuration
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: View
- Request (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
- Return (Outgoing) Mappings: the attributes being passed out of the View Action via the lookup connector
For the full list of View action , see PropertiesView Action Properties.
Views vs Lookups
For more information on views, see View Action Configuration.
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 Viewaction on the canvas
- Alternatively, click onto any empty space on the canvas to create a new View Action
Example Uses
Lookups are useful in many scenarios.
Example: Dynamic Parameters are Needed, e.g. where two lookups are used and the results of the second lookup are determined by the first
Solution: See how-to guide, Lookups with Dynamic Parameters.
Worked Example
Here's a worked example using the School Data (available from the Learning Centre).
In this example, we are using:
- A Classroom Management screen - this screen was created using the Tile with Buttons template, and contains:
- A basic card container of the Classroom data
- A basic card container of the Courses data
- An empty string field, FilterField
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 Classroom Management screen.
Lookup to Classroom Courses
In this example, we want to see the courses held in each classroom when each classroom is clicked. To do this, we will use the classroom data to lookup and retrieve the associated courses data, then output that data back to the screen where it can be used to filter the courses data.
To do this it we will:
- Lookup the courses using the Classroom ID, which is found on both the Classroom and Course tables
- Write those courses' Course ID(s) back to the screen onto a string field
- Setup a background filter to only show courses in a Courses card container that match the Course ID in the field
Event Handler Setup
Event handlers facilitate actions occurring in response to a user action. For this example, we want a user clicking on a classroom card to run an Actionflow that populates a string field that we will later to use to filter the information that can be seen on screen
- Click on the top card on the Classroom Management screen to open the for the area, Card Properties
- Click on the Actions tab
- Click the icon in the Event Handler section
- In the New Card (On Click) Event Handler tab, click Apply
- Enter a name for the Actionflow:
- Name:
Filter Courses
- Name:
- Enter a name for the Actionflow:
Create Calculate Action and Lookup
- Select Click to Connect and for the input, choose the Classrooms Card Component, then select Connect Input
- In the Mappings window that opens, drag the ClassroomID attribute from the left to the right
- Select Save
- Click and drag the icon from the toolbar onto the canvas Calculate
- In the Create Calculate Action window enter:
- Name:
GetCourses
Select Create Action
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 action node Calculate icon onto the
- Right-click on the in connector and choose Open Mappings
- Drag the ClassroomID attribute on the left onto the Drag and Drop area on the right
- Select Save
- To look up to the School_Courses table, hover over the action node and choose, Add Lookup Calculate
- On the Add Connection Point window, name the lookup:
luc
- We recommend choosing a name to indicate the action taking place, e.g. "luc" for look up courses
- Click Confirm
- On the Add Connection Point window, name the lookup:
- With the red arrow attached to your mouse, click anywhere on the canvas
- In the Create View Action window enter:
- Name:
Courses
- Primary Table: choose School_Course
Select Create Action
- Name:
Configure the Lookup
- The Output Attribute Selection window will open automatically
- Click the tick box next to CourseID
- Click Next
- The Request (Incoming) Mappings window will open automatically
- Drag the ClassroomID attribute from the left (Calculate Action) into the Drag and Drop area on the right to create a corresponding attribute in the action View
- Select Next
- The Return (Outgoing) Mappings window will open automatically
- Drag the CourseID attribute from the left (View Action) to the Drag and Drop area on the right to map a corresponding attribute back to the action Calculate
- Click Confirm and Create Filter
- Drag the CourseID attribute from the left (View Action) to the Drag and Drop area on the right to map a corresponding attribute back to the action Calculate
- We need to filter the data coming out of the lookup
- Name:
ByClassroomID
- Click abc to tell PhixFlow to interpret the field as an expression
- Filter Conditions:
- In this filter, the top CourseID is from the Courses data, and the bottom CourseID is from the Classroom data
- Select Finish
- Name:
Checkpoint
Configure the Calculate Action and Output
- Click on the action on the canvas to open its Calculate Properties tab
- In the Output Attributes section, click the
- Name:
CourseIDArray
- Type: Choose
Structured Data
This will return the results as an array
- Expression:
luc.CourseID
Click Apply and Close
icon to create a new attribute: - Name:
Under Connections on the left, select
AddAdd an Output Connection Point:
- Name:
output
Type: choose Output
- Click Create Connection Point
- Name:
- In the Connect Output window, choose the ClassroomAvailabilityManagement , then Connect Output Form
- Close the Mappings window that opens as we don't have any attributes to map to this yet
- Hover your mouse over the action on the canvas and click out Calculate
- When the red arrow shows, click on the
- On the Mappings window, drag across the CourseIDArray attribute from the Calculate action into the Drag and Drop area on the right to create a corresponding attribute on the output
- Click Save
node under Connections - Click the output connection point, under Connections
- On the Mappings window, drag the CourseIDArray attribute from the output to the string field, FilterField
- Click Save
- The Actionflow is now built
Checkpoint
Setting up a Background Filter
The Event Handler and Actionflow will now populate the string field, FilterField, by clicking each classroom card, but the Courses card container needs a background filter setting so it can be filtered by the values in the string field.
- Return to the Classroom Management screen
Click on the Courses card container to open the Card Component Properties
- Ensure you click on the white space underneath the top contact card to open the Card Component
On the , in the Properties tab Background Filter Rules section, click
- Enter the Rule Expression:
true
- Enter the Rule Expression:
- Create a new filter by pressing
- Name:
ByFilterField
- In the Filter Details section, click Select an option and choose the CourseID in the Table Attributes
- Filter Details:
- Click on both the Filter and Filter Rule Apply and Close Properties
next to Filter: - Name:
- the screen and click a classroom card to see the Actionflow working Lock
Having trouble? See Troubleshooting above.
Once you have verified the Actionflow is working, the FilterField string field can be hidden in the or Styles tab to tidy up the screen. Layers