Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
_Banners
_Banners
nameactionflow
nopaneltrue

What is

an Actionflow?An Action

a HTTP Action?

HTTP actions performs HTTP(S) requests to external APIs and returns the response.

A HTTP action has two outputs. One input request will generate one output record, which will be sent on either the out or error output. A HTTP request will be triggered for each input record and generate one output record.

The response from the server (headers and body) will be treated as the result record, with the input attributes added as passthrough fields.


  • URL: A template the computes to the URL of the request (including protocol).

  • Method: The HTTP method. A drop down containing [GET, POST, GET or POST, HEAD, PUT, DELETE, other]. If other is specified a text box will allow entering of custom, none empty, uppercase letters only.

  • Headers: A table of name, value pairs. The name will be treated as a case insensitive string, the value will be treated as a template expression. Duplicate names are permitted and should result in each value being sent in the request.

  • Body: An optional template expression. If this evaluates to only whitespace then it is not include in the request

  • Error expression: An optional JEP expression to determine if the response is an error and so sent on the error output.

An Output Attributes section will be available on the http action editor. This will work the same way as the calculate and extractor nodes operation.

The attribute expression will have access to the input (in) and an _result record.

The result record will be structured equivalently to the following JSON document (there is no requirement to actually generate a JSON string to produce the document, just conceptually this is what the string would look like and JEP should operate as if it had come from the equivalent string.

  • Result fields

    • body: the response body as a string (string)

    • url: the url the request was sent to (string)

    • status: the returned status code as an in (getCode()) (int)

    • status message: the returns status message (getReasonPhase()) (string)

    • status family: the returned status code family (100, 200, 300, 400, 500) (int)

    • error: true if internalError is true, or the error expression (or default expression) returned true (TrueFalse)

    • transmissionError: true if the error was generated internally by PhixFlow (e.g. a pseudo response for connection timed out etc) (TrueFalse)

    • headers: a map of header names → array of values ( headerName : [value1, value2]} (Structured Data)

The output attributes will default to have:

  • status: _result.status

  • status_message : _result.status_message

  • contentType: _result.headers.”Content-Type”

  • body _ result.body


Worked Example

Here is a worked example using the Shop Data (available from the Learning Centre).

In this example, we are using:  

  • 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 Dates

In this example, we'll create an Actionflow that checks if a new customer's name matches any existing customers, then shows this information in a pop up.

Example

Bank Holidays

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

Shop Shipping Screen

Shop Shipping Popup Screen

Table Setup

  1. Create a new
    Insert excerpt
    _tables
    _tables
    nopaneltrue
     on your
    Insert excerpt
    _erd
    _erd
    nopaneltrue
     to save the bank holiday data to, and ensure it contains the following attributes:
    1. Name: UID
      1. Type: String
      2. Length: 50
      3. Expression: _NULL
    2. Name: Name
      1. Type: String
      2. Length: 200
      3. Expression: _NULL
    3. Name: Date
      1. Type: Date
        1. Leave the Expression field blank
    4. Name: Country
      1. Type: String
      2. Length: 50 
        1. Leave the Expression field blank

Initial Configuration

  1. On the Shop Shipping screen, add an Actionflow to the Image Added button ("GetDates")

  2. Add an Actionflow to the button that is triggered by the button click

    Expand
    titleHow?

    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.

    1. Open the 
      Insert excerpt
      _property_settings
      _property_settings
      nopaneltrue
       for the button and click on the 
      Insert excerpt
      _property_tabs
      _property_tabs
      nameaction
      nopaneltrue
    2. In the Action Settings section, choose an Action Method of Actionflow
    3. Create a new Actionflow



HTTP Action Setup

  1. Select Click to Connect and choose On Click
  2. Drag a 
    Insert excerpt
    _http
    _http
    nopaneltrue
     action onto the canvas and give it a suitable name - this will be used to retrieve the bank holidays from the government JSON URL
  3. Drag the 
    Insert excerpt
    _input
    _input
    nopaneltrue
     connection point node onto the
    Insert excerpt
    _http
    _http
    nopaneltrue
     action
  4. Click on the 
    Insert excerpt
    _http
    _http
    nopaneltrue
     action to open its Properties
    1. HTTP Method: GET
    2. URL: https://www.gov.uk/bank-holidays.json
    3. Log Traffic: 
      Insert excerpt
      _toggle_on
      _toggle_on
      nopaneltrue
    4. Maximum HTTP Log Length: 100000
  5. Drag a 
    Insert excerpt
    _action_json
    _action_json
    nopaneltrue
     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
  6. Connect the out connector from the HTTP node to the JSON node
  7. Click on the connector between the 
    Insert excerpt
    _http
    _http
    nopaneltrue
     action and the
    Insert excerpt
    _action_json
    _action_json
    nopaneltrue
     action
    1. Map across all attributes

JSON Action Setup

  1. Click on the 
    Insert excerpt
    _action_json
    _action_json
    nopaneltrue
     action to open its Properties
    1. Input Expression: in.body
    2. Path: $..events
    3. Output Attributes:

      Code Block
      themeEmacs
      titleName: Country, Type: String
      _result.^.^.division


      Code Block
      themeEmacs
      titleName: Date, Type: Date
      toDate(_result.date, "yyyy-MM-dd")


      Code Block
      themeEmacs
      titleName: ID, Type: String
      toString(_result.date, "yyyyMMdd") + substring(_result.^.^.division, 1,1)


      Code Block
      themeEmacs
      titleName: Title, Type: String
      _result.title


  2. Hover over the JSON action and select out
  3. Create a
    Insert excerpt
    _action_save
    _action_save
    nopaneltrue
     action
    1. Primary Table: Shop Bank Holidays

Save Action and Open Screen Action Setup

  1. Click on the connector between the JSON action and the Save action
  2. Map across the JSON attributes to their relevant attributes on the Save action

    Expand
    titleHow?

    Image Added


  3. Hover over the Save action and choose out
  4. Create an 
    Insert excerpt
    _action_screen
    _action_screen
    nopaneltrue
     action to open the Shop Shipping Popup screen

Testing

  1. Close all open screens and reopen the Shop Shipping screen
  2. Click the Image Added button to run the Actionflow
  3. 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

Tidy up your popup screen by adding a background filter to show the most recent bank holidays.

  1. On the Shop Shipping Popup screen, configure a Background Filter on the

    Insert excerpt
    _action_view
    _action_view
    nopaneltrue
     Configuration to only show future dates 

    Expand
    titleHow?
    1. Right-click on the grid and choose, Show the View Configuration
    2. In the Data Retrieval Options section of the Properties, select the 
      Insert excerpt
      _addIcon
      _addIcon
      nopaneltrue
       icon to create a new background filter
    3. Image Added


1.02 Actionflow Principles