Here is a worked example using the Retail 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. |
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. Image Added 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
HTTP Action SetupOn the Shop Shipping screen, add an Actionflow to the Image Added ("GetDates") button 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
- 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
Map across attribute, body
Expand |
---|
| Image Added |
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: The Bank Holidays table you created earlier
- Map across the JSON attributes to their relevant attributes on the Save action
Expand |
---|
| Image Added |
- 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 Expand |
---|
| Image Added |
Screen Setup- Open the Shop Shipping Popup screen
- Click on
Insert excerpt |
---|
| _attributes |
---|
| _attributes |
---|
nopanel | true |
---|
| in the toolbar, then select the Bank Holidays table you created earlier - In the Available Attributes selector, select all attributes and drag them onto the screen, then choose to display the data as a
Testing- Close all open screens and reopen the Shop Shipping screen
- Click the Image Added 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 your Shop Shipping Popup screen by hiding the UID column on the grid, adding a Default Filter to show only bank holidays in the future, and Default Sort Order to show the most recent bank holidays first.
Expand |
---|
| - Right-click on the grid and choose,
Insert excerpt |
---|
| _view_show_config |
---|
| _view_show_config |
---|
nopanel | true |
---|
|
- In the Data Retrieval Options section of the Properties:
- For Background Filter, select the
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
| icon to create a new background filter - Image Added
- For Default Sort Order, select the
Insert excerpt |
---|
| _addIcon |
---|
| _addIcon |
---|
nopanel | true |
---|
| icon to create a new sort order - Image Added
|
|