Worked ExampleHere is a worked example using the Shop Data (available from the Learning Centre) and JSON data from the UK government website (https://www.gov.uk/bank-holidays.json). In this example, we are using: - A Shop Shipping screen containing a grid of Orders data, a grid of Order Lines data, an area containing a Date form field and buttons - this screen was created using the Multi-Tile template
- A Shop Shipping Popup screen containing a grid of the bank holiday data - this screen was created using the Tile no Buttons 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 Intermediate Application. For these example, we'll be working on the Search button on the Shop Shipping screen, and the Shop Shipping Popup screen. |
GIF/SCREENSHOT OF FINISHED RESULT Identify Bank Holiday DatesIn this example, we'll create an Actionflow that retrieves bank holiday dates in the UK from the government website in JSON format and map this onto a screen in a grid. HTML Comment |
---|
| Select shipment date date field (date picker), then press Ship Date which changes the status of the order and order lines to completed. Area underneath showing upcoming bank holidays |
Table Setup- Create a new
Insert excerpt |
---|
| _tables |
---|
| _tables |
---|
nopanel | true |
---|
| on your to save the bank holiday data to, and ensure it contains the following attributes:- Name:
UID - Type:
String - Length:
50 - Expression:
_NULL
- Name:
Name - Type:
String - Length:
200 - Expression:
_NULL
- Name:
Date - Type:
Date - Leave the Expression field blank
- Name:
Country - Type:
String - Length:
50 - Leave the Expression field blank
Initial ConfigurationOn the Shop Shipping screen, add an Actionflow to the Image Modified button ("GetDates") Add an Actionflow to the button that is triggered by the button click Expand |
---|
| You may notice that right-clicking the button does not display the option to add an Actionflow. The Actionflow must be created using an event handler. See 2.01 Connecting Actionflows to Events. - Open the
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
| for the button and click on the Insert excerpt |
---|
| _property_tabs |
---|
| _property_tabs |
---|
name | action |
---|
nopanel | true |
---|
|
- In the Action Settings section, choose an Action Method of Actionflow
- Create a new Actionflow
|
HTTP Action Setup- Select Click to Connect and choose On Click
- Drag a action onto the canvas and give it a suitable name - this will be used to retrieve the bank holidays from the government JSON URL
- Drag the connection point node onto the action
- Click on the action to open its Properties
- HTTP Method: GET
- URL: https://www.gov.uk/bank-holidays.json
- Log Traffic:
Insert excerpt |
---|
| _toggle_on |
---|
| _toggle_on |
---|
nopanel | true |
---|
|
- Maximum HTTP Log Length: 100000
- Drag a
Insert excerpt |
---|
| _action_json |
---|
| _action_json |
---|
nopanel | true |
---|
| action onto the canvas and give it a suitable name - this will be used to convert the JSON data into data suitable for our bank holiday table - Connect the out connector from the HTTP node to the JSON node
- Click on the connector between the action and the
Insert excerpt |
---|
| _action_json |
---|
| _action_json |
---|
nopanel | true |
---|
| action- Map across all attributes
JSON Action Setup- Click on the
Insert excerpt |
---|
| _action_json |
---|
| _action_json |
---|
nopanel | true |
---|
| action to open its Properties- Input Expression:
in.body - Path:
$..events Output Attributes:
Code Block |
---|
theme | Emacs |
---|
title | Name: Country, Type: String |
---|
| _result.^.^.division |
Code Block |
---|
theme | Emacs |
---|
title | Name: Date, Type: Date |
---|
| toDate(_result.date, "yyyy-MM-dd") |
Code Block |
---|
theme | Emacs |
---|
title | Name: ID, Type: String |
---|
| toString(_result.date, "yyyyMMdd") + substring(_result.^.^.division, 1,1) |
Code Block |
---|
theme | Emacs |
---|
title | Name: Title, Type: String |
---|
| _result.title |
- Hover over the JSON action and select out
- Create a
Insert excerpt |
---|
| _action_save |
---|
| _action_save |
---|
nopanel | true |
---|
| action- Primary Table:
Shop Bank Holidays
Save Action and Open Screen Action Setup- Click on the connector between the JSON action and the Save action
Map across the JSON attributes to their relevant attributes on the Save action Expand |
---|
| Image Modified |
- Hover over the Save action and choose out
- Create an
Insert excerpt |
---|
| _action_screen |
---|
| _action_screen |
---|
nopanel | true |
---|
| action to open the Shop Shipping Popup screen
Testing- Close all open screens and reopen the Shop Shipping screen
- Click the Image Modified button to run the Actionflow
- If the Actionflow is working, the Shop Shipping Popup screen should open containing all of the bank holiday data from the government website
Background Filter and Default Sort OrderTidy up |