What
is a For Each Action?Image Removed
The are Drag Types and Drop Targets?
Drag and drop actions allow users to click and drag an item from location to another within a screen. This allows users to intuitively interact with content, rearrange items, and trigger further actions by dropping onto a designated area. Some examples of drag and drop actions are:
- Dragging a record from a grid onto a delete area to remove it
- Dragging a contact from a grid onto a specific company on a company table to move that contact to that company
- Dragging items into different sections on a Kanban board to change the state of the record - see Making Kanban Boards
To set up drag and drop on components, a Insert excerpt |
---|
| _drag_type |
---|
| _drag_type |
---|
nopanel | true |
---|
|
on the object you are dragging from and a
Insert excerpt |
---|
| _drop_target |
---|
| _drop_target |
---|
nopanel | true |
---|
|
on the object you are dropping onto is required. Components that can have Insert excerpt |
---|
| _drag_type |
---|
| _drag_type |
---|
nopanel | true |
---|
|
are:Any component which has an
Insert excerpt |
---|
| _actionproperty_foreachtabs |
---|
| _property_tabs |
---|
name | action_foreach |
---|
nopanel | true |
---|
|
action iterates over a set of records or list of values, and generates an output record for each one. It is most commonly used to split data, such as an array, into individual records, or it can be used in conjunction with a can be a Drop Target. The Drop Action (performed when the drop occurs) is configured in an Actionflow on the Drop Target.Image Added
For example, to assign a new company to an employee, a user creates two grids on a screen. The employee and company table have a relationship and are linked by a CompanyIDfield. The employee can be dragged and dropped onto a company to update CompanyID attribute for the employee.
Creating Drag and Drop Actions
Insert excerpt |
---|
| _drag_type |
---|
| _drag_type |
---|
nopanel | true |
---|
|
s and
Insert excerpt |
---|
| _actiondrop_calculatetarget |
---|
| _actiondrop_calculatetarget |
---|
nopanel | true |
---|
|
action to firstly convert a user-inputted list into an array for the s are set on components on a screen.Creating a Drag Type
- Right-click on the grid and select
action
for
each
action
for
each
action to process - see worked example below. Creating For Each Actions
- Click and drag the on the component from which data will be dragged
On the Insert excerpt |
---|
| _property_tabs |
---|
| _property_tabs |
---|
name | action |
---|
nopanel | true |
---|
|
, in the Action Settings section, under Drag Type, select or create a drag type, e.g. Move Contact
- If creating a Drag Type, click the actionforeachactionforeach icon from the toolbar onto the canvas button
- Name: Enter a name
in the Create For Each Action window and select Create ActionIn - for the drag type
- Attributes: create the attributes to be used in the Actionflow, e.g. CompanyID
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
- A Drag Mappings section will become available in the Action Settings
- Click the
Insert excerpt |
---|
| _mappings_configure |
---|
| _mappings_configure |
---|
nopanel | true |
---|
|
button - Map across attributes from the table onto the actionforeachactionforeach action attributes set above, to be used within the Actionflow
Components with a drag type can be dragged and dropped onto any component which has a drop target with a matching drag type.
Creating a Drop Target
Input Attributes | Attributes mapped into the For Each action will appear here. If adding a new input attribute, a Name and Type are required. See Understanding Data Types. | Output Attributes | Attributes mapped out of the For Each action will appear here.
If adding a new output attribute, a Name, Type and Expression are required. This is a PhixScript expression. Values returned by the Input Expression are available in this expression as:
To work in a larger popup window, click Insert excerpt |
---|
_editor_expand | _editor_expand | nopanel | true |
.See also:
Name: Invoices Type: String Expression: _result.value | HTML Comment |
---|
|
Insert excerpt |
---|
For Each Node | For Each Node | name | page |
---|
nopanel | true |
Worked Example- Click on the component where data will be dropped to open the
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
on the right, populate the following:
Field | Description | Example Value |
---|
Input Expression | The input expression provides the source of the data to be iterated over. Typically, this will be a simple expression pointing at an Input Attribute, using the syntax, Connector.AttributeName. If an empty record set or empty list is provided then no output will be generated. This field is mandatory (PhixFlow version 11.1 +). | // Receives a list of Invoice IDs, these are iterated over using in.InvoiceID
|
- On the
Insert excerpt |
---|
| _property_tabs |
---|
| _property_tabs |
---|
name | action |
---|
nopanel | true |
---|
|
, in the Drop Targets section, select or create a drop target, e.g. Add Contact
- If creating a Drop Target, click the
Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
button- Name: Enter a name for the drop target
- Drag Type: Select the drag type (e.g. Move Contact) that matches the drag type set on the component being dragged
- Drop Action: Select
Insert excerpt |
---|
| _actionflow |
---|
| _actionflow |
---|
nopanel | true |
---|
|
- Actionflow: Select or create an Actionflow to run when a component with a matching drag type is dropped onto this component
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
- If creating an
Insert excerpt |
---|
| _actionflow |
---|
| _actionflow |
---|
nopanel | true |
---|
|
, select the Insert excerpt |
---|
| _drag_type |
---|
| _drag_type |
---|
nopanel | true |
---|
|
as the an - Map in the attribute(s) created on the
Insert excerpt |
---|
| _drag_type |
---|
| _drag_type |
---|
nopanel | true |
---|
|
- Then configure your Actionflow as required, e.g. delete a record, move that contact to a company, change the state of the record, etc.
Worked Examples
Here's a worked example using the Company Data (available from the Learning Centre).
In this example, we are using:
- A Company For Each ExampleApproval Review screen containing:
- an multi-line string field and Save button that will be used by the user to enter a list
- a string field that will be used to create a filter
- a grid backed by the ForEachExample tablea grid backed by the Companies table
- with a Background Filter to only companies where their Status does not equal Approved or Rejected
- two areas containing Approve and Reject icons - this screen was created using the Multi-Tile template
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 Advanced Application. For this example, we'll be working on the Company For Each ExampleApproval Review screen. |
Split a List Into Individual RecordsExample 1: Approve Company Using Drag and Drop
In this example, we'll take a list of values inputted by a user and convert these into individual records.
Image Removed
Actionflow Setup
Open the Company For Each Example screenAdd an configure company records on a grid to be draggable, and set up an area on a screen as a drop target to receive the record(s). When a company is dropped in the area, its Status will be updated to Approved. We'll add some additional processing to our Actionflow to update the audit details on the record, showing who made the change, along with the date and time.
Image Added
Drag Type Setup
- Open the Company Approval Review screen by clicking on the Approvals button in the top menu
- Right-click on the Companies Pending Review grid and select
Insert excerpt |
---|
| _view_actionflowshow_config |
---|
| _view_actionflowshow_config |
---|
nopanel | true |
---|
|
to the Save button - Configure the Input as the CompanyForEachExample form
- Map the attribute Text into the Actionflow
Calculate Action - Convert List to Array
Use the split function in a - Click the
action
calculatetabs | | _property_tabs |
---|
name | action |
---|
|
_calculate
action to split the Text attribute by the comma separator. This will convert the list entered by the user into an array. Expand |
---|
|
Create a - In the Action Settings section, click the
action
calculate
action
calculate
actionConnect the - icon next to
input
input- to
the Calculate action- Map across the Text attribute
In the Calculate action, create an Output Attribute- create a new drag type:
- Name:
Split
Type: Structured Data
Expression: split(in.Text,",")
Expand |
---|
|
Image Removed |
Calculate Action - Create Session ID (Optional)
Create a SessionID attribute in a Company
- Click
- Attributes: select
action
calculate
action
calculateName: SessionID
action to allow identification of records created at the same time, which we will use for filtering. Expand |
---|
|
In the Calculate action, create another Output Attribute:- Name:
CompanyID
- Type:
String
Expression: now() + _user.username
-
Integer
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
Expand |
---|
|
Image Removed |
For Each Action - Convert Array to Records
Use a - the Drag Type tab
- A Drag Mappings section will become available in the Action Settings on the View
- Click the
action
for_each
action
for_each
action to convert the array into individual records.- Create a button
- Map across the CompanyID attribute from the Companies for_eachfor_each action
- Name:
Convert to Records
- Connect it to the Calculate action and map across the Split attribute
- On the For Each action, enter the following:
- Input Expression:
in.Split
- Input Attributes:
Split
Create two Output Attributes: - Name:
Name
- Type:
String
- Expression:
trim(_result.value)
- The trim function is used here to remove the whitespace after the comma separator in the list
- If this was not used and the list "one, two, three" was entered, the records "two" and "three" would be saved with prefixed whitespace
Name: LastUpdated
- Type:
Datetime
Expression: now()
to the Insert excerpt |
---|
| _drag_type |
---|
| _drag_type |
---|
nopanel | true |
---|
|
- Click Confirm Mappings
Insert excerpt |
---|
| _finish |
---|
| _finish |
---|
nopanel | true |
---|
|
Expand |
---|
|
Image Removed |
Create a Sequence Number for UID (Optional)
Create a Sequence in your application to give each record a unique value. Alternatively, the UID attribute can be left unmapped and PhixFlow will automatically create a unique identifier.
- Open the the View
Drop Target Setup
- On the Company Approval Review screen
- Click on the area holding the Image Added icon
- Ensure the
Insert excerpt |
---|
| _repositoryproperty_settings |
---|
| _repositoryproperty_settings |
---|
nopanel | true |
---|
|
for your applicationExpand the area, OuterBorderTop, is selected - Click the
Insert excerpt |
---|
| _sequencesproperty_tabs_sequences |
---|
| _property_tabs |
---|
name | action |
---|
nopanel | true |
---|
|
- option, then click In the Drop Targets section, click the
Insert excerpt |
---|
| _add_icon |
---|
| _add_icon |
---|
nopanel | true |
---|
|
- Name:
Unique_ID
- Start Value:
1
Block Size: 1
icon to add a new drop target:- Name:
CompanyApproval
- Drag Type: Select the Company Drag Type you set up above
- Drop Action:
Actionflow
- Actionflow: click
finish
finish
Image Removed
Add the Sequence Number to the UID Attribute (Optional)
Create an Output Attribute, UID, on the - to create a new Actionflow
- Name:
Company Approval
Actionflow Setup
- Connect the input of the Company
Insert excerpt |
---|
| _drag_type |
---|
| _drag_type |
---|
nopanel | true |
---|
|
- Map in the CompanyID attribute
- Create a
for_each
for_each- action
using the Sequence you created above. - Name:
Update Status and Audit
- Add three Output Attributes:
- NewApprovedStatus: this should contain a string with the new status
- NewUpdatedByName: this should contain details of the user making the change using the internal variable _user - see Internal Variables
- Review the Companies table data to see the formatting of this attribute
NewUpdatedByTime: this should contain the date and time the user updates the record
On the For Each action, create an Output Attribute: - Name:
UID
- Type:
Integer
- Expression:
nextValue('Unique_ID')
Insert excerpt |
---|
_finish | _finish | nopanel | true |
Code Block |
---|
theme | Emacs |
---|
title | Name: NewApprovedStatus, Type: String |
---|
| "Approved" |
Code Block |
---|
theme | Emacs |
---|
title | Name: NewUpdatedByName, Type: String |
---|
| _user.name + " (" + _user.fullUsername + ")" |
Code Block |
---|
theme | Emacs |
---|
title | Name: NewUpdatedTime, Type: Datetime |
---|
| now() |
|
Image RemovedImage Added |
Save Action
Use a
- Connect the
action_save
action_save- to
save the data to the ForEachExample table. Expand |
---|
|
Create a - the
save
save- action
for the ForEachExample tableConnect it to the For Each actionMap across all attributes from the For Each actionMap across the SessionID attribute from In the Save action - Hover over the Calculate action and click,
if created- out
- Click anywhere on the canvas to create a new
property
settings
property
settings
, change the Type to Insert
Image Removed
Output - Map SessionID Onto Screen (Optional)
If you have created a SessionID attribute, an output will need to be created to map this value onto the SessionID String Field on the screen, so that it can be used for filtering.
Expand |
---|
|
Under Connections, create an output connection point to the CompanyForEachExample formHover over the Save action and click, out, then select the Insert excerpt |
---|
_output | _output | nopanel | true |
nodeMap across the SessionID attribute from the table (not the Calculate action) to the outputClick on the output connector under Connections and map the SessionID attribute from the output to the screen- action
- Name:
Save Company
- Type:
Update
- Table:
Companies
- Map across the three attributes created by the Calculate action onto their relevant attributes in the Companies table, and the CompanyID from the input
Expand |
---|
|
Image Removed |
Filter Setup (Optional)
On the Company For Each Example screen, open the view configuration for the gridCreate a Default Filter that filters the view by the values in the SessionID field
Expand |
---|
|
Image Removed |
Testing
On the Company For Each Example Image Added |
Testing
- Close and reopen the Company Approval Review screen, the screen
- Enter a list into the Text field, e.g. Extra Small, Small, Medium, Large, etc. and click Save
- Your list will be converted into individual records in the grid
- Enter another list and you will see that the previous list disappears as the grid is being filtered by the SessionID
- Once you have confirmed your default filter is working, hide it
3.09 Loop Action Configuration- Drag a company from the Companies Pending Review grid onto the Approve icon
- The company should be removed from this screen and instead appear on the Companies screen
Example 2: Reject Company Using Drag and Drop (Optional)
Repeat the steps above to set up the area holding the Image Added icon as a Drop Target. Remember to change the Expression in the Output Attribute to "Rejected".
Image Added
Image Added