Versions Compared

Key

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

Insert excerpt
_Banners
_Banners
nameactionflow
nopaneltrue

What is

an API End Point?

a Bulk Delete Action?

Image Added

The 

Insert excerpt
PhixFlow Incoming APIPhixFlow Incoming APInameAPI_end_point_action_bulkdelete
_action_bulkdelete
nopaneltrue

Incoming API Setup

To enable an Actionflow to receive incoming APIs, it must be defined as an end point, and have a set of predefined input parameters configured on its incoming connection point. These settings are described below:

Step 1 - Actionflow Properties

Create an  Insert excerpt_actionflow_actionflow

 action deletes records in bulk from a table, such as deleting all records, or those records which satisfy the specified filter criteria set on the node. 

Note: Bulk Delete actions will only delete records in tables with the Period of Transactional.

Insert excerpt
Save Action Configuration
Save Action Configuration
nameTablePeriod
nopaneltrue

 from the Actionflow home page
  • Set a unique name and provide a useful description
  • When the Actionflow opens, on the toolbar click 

    For the full list of Bulk Delete

    Insert excerpt
    _property_settings
    _property_settings
    nopaneltrue

  • In the API section of the properties, enable API End-Point
    1. This allows the Actionflow to receive an incoming API
  • Enable Allow Anonymous Connections
    Excerpt
    nameAllowAnonymousConnections

    This allows anyone with the URL for the API to call it. The audit trail records the system as running performing the API call.

     Adding authorisation is covered later on this page.

    , see Bulk Delete Action Properties.

    Insert excerpt
    _action_

    save

    delete
    _action_

    save

    delete
    nopaneltrue

     your changes

    Step 2 - Input Connection Point Input Parameters

    Incoming APIs require a specific set of Input Parameters on the connection point.

    Click on the

     vs 
    Insert excerpt
    _action_bulk_

    input

    delete
    _

    input

    action_bulk_delete
    nopaneltrue

     Connection Point
  • In the Properties that open, in the Input Parameters section, add the following attributes (the names are case sensitive):
  • NameTypeDescriptionbodyStringprovides the information sent in the body of the API call.contentTypeStringProvides details of the Content TypeheadersStringProvides the information sent in the API call header.urlStringProvides the complete URL that was used to call the API. This can be used to pass parameters to the API.   3.  Insert excerpt_save_savenopaneltrue your changes

    Step 3 - Configure your Actionflow

    Configure the Actionflow to perform the required tasks.

    If you wish to return data from the API:

    1. Add a new Connection of type Output
      1. The name of the Output Connection Point will be used to retrieve the data as part of the path. This is covered in Calling a PhixFlow API below.
    2. Add the required Output Attributes, i.e. the data you wish the API to return - this is optional

    Calling a PhixFlow API

    Step 4 - HTTP Method and API Mode

    1. HTTP Method
      1. To call a PhixFlow API use the HTTP Method GET or POST:
      2. GET simply calls the API with data passed in the body of the request.
      3. POST calls the URL and sends data in the body of the request. The body data is passed into the body attribute of the Actionflow setup above as an Input Connection point. 
    2. API Mode
      1. Wait for result (Synchronous) (Default): The API waits for the results or the timeout to occur. Note: If the timeout occurs the command is aborted.
      2. Poll for result (Asynchronous): The API is called and a response is returned immediately including the process ID. Subsequent API calls can be made using the process ID to fetch the status of the action. The asynchronous mode can be thought of as “fire and forget”.

    Step 5 - API URL

    The API URL can be found in the Actionflow Properties → API Section → URL value

    Example URL: https://app.phixflow.com/phixflow/api/1/action/MyApp/My%20API/trigger

    Expand
    titleUrl Structure

    The structure of the URL is as follows:

    https://<<Server Name>>/phixflow/api/1/action/<<Application Name>>/<<Actionflow Name>>/trigger

    parameterdescription<<Server Name>>URL of the server e.g. app.phixflow.comphixflowthe name of the instance, typically this is phixflow<<Application Name>>The name of the application where the Actionflow resides.<<Actionflow Name>>The name of the actionflow set in Step 1. Note that if your actionflow has a space in the name this must be replaced with %20. For example "My API" becomes, "My%20API". 

    note: In version 10 the url structure differed, this old structure has been deprecated: https://<<Server Name>>/phixflow/api/1/action/<<Actionflow Name>>/trigger 
    Integrations using this old structure should be updated, however the url structure will still work in version 11.

    Step 5.1 - API Status Check (Poll for Result)

    1. If calling a PhixFlow Asynchronous API only, a result will be immediately returned which includes a Process ID for that run.
    2. The Process ID is returned on the path:
      1. $.processId
      2. This can be accessed in an Output attribute using, _result.value
    3. The Process ID can be used to call the following URL which will return the current state of the run:
      1. https://<<Server Name>>/phixflow/api/1/action/<<Application Name>>/<<Actionflow Name>>/poll/<<processID>>

    Step 6 - Returned Data JSON Path

    If your API has been configured to return data the path will be in the format:

    $.data.<<Output Name>> 

    Where <<Output Name>> is the Output connection point setup in step 3.

    Adding Authentication

    Step 7 - Enable Authentication

  • Open the Incoming API Actionflow.
  • On the toolbar click  Insert excerpt_property_settings_property_settingsnopaneltrue
  • In the Basic Settings section of the properties, click Allow Anonymous Connection so that it is disabled, it will appear greyed out.
  • Insert excerpt_save_savenopaneltrue the changes

    Step 8 - Create an Authentication User

    In the Insert excerpt_repository_repositorynopaneltrue, expand the application with the Incoming API.Expand Insert excerpt_roles_rolesnopaneltrue and create an New Role by clicking  Insert excerpt_addIcon_addIconnopaneltrue.
  • Pin the tab as we will need it to remain open.
  • Provide a useful Name e.g. GenerateToken
  • In the Privileges section, click  Insert excerpt_privilege_privilegenopaneltrue
  • Scroll down to the Full Repository, expand it and search for  the privilege: Use API Key
  • Drag the Use API Key into the privileges section of the Role.
  • Image Removed
  • Insert excerpt_save_savenopaneltrue the changesIn the  Insert excerpt_user_group_user_groupnopaneltrue section, click  Insert excerpt_user_group_user_groupnopaneltrueAdd a new Group for you Role.
  • Give it a useful Name e.g. API Users.
  • Add any users you require to be able to run the API. This could be a dedicated API user with limited privileges.
    1. To create a user see Managing User Accounts → Creating Users.
  • Click  Insert excerpt_save_savenopaneltrue and close the tab.Now drag the new user group into the  Insert excerpt_user_group_user_groupnopaneltrue section of the new privilege. Insert excerpt_save_savenopaneltrue the changes
  • The setup should look similar to:
    1. Image Removed
  • Step 9 - Authentication Token KeyStore

    A signing key is used to generate the PhixFlow API key and this is stored on the server to ensure secure access.

    Using the page Configure a Keystore and Aliases, configure phixflow-api-key to be used as the signing key for PhixFlow API Keys in the same way as the pepperKey is configured. This secret string must be a minimum of 32 bytes length.

    Step 10 - Generate Authentication Token

  • The Incoming API will run as a specified user, this means when it is called the audit trail will show the specified user as having performed the Incoming API Actionflow
  • You do not need to login as this user, however, if you were already logged in as this user when performing Step 1 above, you will need to logout and login again to pick up the user group change
  • In the  Insert excerpt_repository_repositorynopaneltrue, scroll down to the Full Repository section and expand itExpand the Insert excerpt_user_usernopaneltrue section
  • Double click on the user who will run the Incoming API
  • Click the 3-dot more menu in the top right of the user properties
  • Click Generate API Key
  • Copy the value displayed and store it somewhere safe
  • Step 11 - Send Authorization

    When calling the Incoming API, the authorisation token must be passed in as a header called: Authorization

    Server Console Responses

    The item calling the API End-Point will receive the a Response from the API End-Point stating whether it has run successfully (Success) or not (Fail). Responses can be customised to return specific messages.

    The response recorded in the Insert excerpt_console_consolenopaneltrue:

    If you are making the call using PhixFlow the Responses can be access as follows:

    1. Click the Actionflow entry
      1. Image Removed
    2. In the Messages section which is opened below, double-click the lines that begin Response
      1. Image Removed
    3. Click the Message Details tab to see the response.

    API End-Point Results

    To see the results of the API End-Points processing in the  Insert excerpt_console_consolenopaneltrue:
    1. Click the Actionflow entry for the API End-Point
    2. In the Messages section which is opened below, double-click any of the Messages to see more details
    3. If you are using a debug() statement these will appear here.

    Failures

    An API End-Point will fail if the logic in the Actionflow fails or if the error() function is used to force a failure.

    If records are passed to the API End-Point individually a failure will only impact the specific record being processed.

     

    The key difference between 

    Insert excerpt
    _action_delete
    _action_delete
    nopaneltrue
     and 
    Insert excerpt
    _action_bulk_delete
    _action_bulk_delete
    nopaneltrue
     is that the Bulk Delete action purges records from PhixFlow, including the audit history of records where Audit Manual Changes has been enabled.

    To delete records and persist the audit history of the record, see Delete Action Properties.  

    Creating Bulk Delete Actions

    1. Click the 
      Insert excerpt
      _action_bulkdelete
      _action_bulkdelete
      nopaneltrue
       icon in the Actionflow toolbar to display any existing tables in the application 
      1. Existing tables can be dragged from the Repository onto the canvas, then choose 
        Insert excerpt
        _action_bulkdelete
        _action_bulkdelete
        nopaneltrue
         to create a Bulk Delete node
    2. Alternatively, drag the 
      Insert excerpt
      _action_bulkdelete
      _action_bulkdelete
      nopaneltrue
       icon from the toolbar onto the canvas
    3. In the Create Bulk Delete Action window:
      1. Enter a Name
      2. Choose a Type from: 
        1. Delete: allows only records satisfying the specified filter criteria to be deleted
          1. Set the filter criteria in the Bulk Delete Action 
            Insert excerpt
            _property_settings
            _property_settings
            nopaneltrue
             under Data Retrieval Options - see section below
        2. Delete All: deletes all data from the selected table 
      3. Choose to Allow Audited Table to display tables with Audit Manual Changes enabled in the Table drop down
        1. By default, tables with Audit Manual Changes enabled are not shown in the Table drop down list
      4. Choose the Table from the drop down where the records will be deleted
        1. Or click the table icon to display tables in the Repository
      5. Select Create Action

    When creating delete actions it can be useful to set up confirmation messages that allow users to confirm or cancel the deletion. See Confirmation Message Configuration

    Setting Delete Action Filter Criteria

    Where the Type is set to Delete on the

    Insert excerpt
    _action_bulkdelete
    _action_bulkdelete
    nopaneltrue
     action, the Data Retrieval Options section shows in the 
    Insert excerpt
    _property_settings
    _property_settings
    nopaneltrue
    . This filter must be set for the Bulk Delete action to run.

    Image Added

    1. Choose a Data Range from:
      1. Latest: selects data from the latest recordsets
      2. All: selects data from all recordsets (default)
    2. Set the Filter Criteria to specify which records will be selected for deletion. See Filter → Filter Details
      1. Incoming attributes mapped to the Bulk Delete node can be referenced in the Data Retrieval Options using the syntax, ConnectorName.AttributeName, e.g. in.MyAttribute
    Excerpt
    nameBatchSize

    Specify Delete Batch Size

    Where the Type is set to Delete on the

    Insert excerpt
    _action_bulkdelete
    _action_bulkdelete
    nopaneltrue
     action, in the Advanced section, an optional Delete Batch Size can be set to determine the size of the batches. If left blank the batch size set in System Configuration → System TuningDelete Batch Size, is used as the default. The System Configuration value can be overridden with this batch size. 

    Bulk Delete Output Attribute (modifiedRows)

    The output attribute, modifiedRows, automatically shows when mapping from a Bulk Delete action. This attribute is a count of the rows that are updated by the action, but if the Type (see above) is set to Delete All then the value is unavailable.

    Image Added

    HTML Comment
    hiddentrue

    Insert excerpt
    Bulk Delete Action Properties
    Bulk Delete Action Properties
    nopaneltrue


    Worked Example

    Here's a worked example using the Company Data (available from the Learning Centre).

    In this example, we are using:  

    • Shop Staff Company Rejected Companies screen containing a grid three grids of the Shop Staff Companies, Orders and OrderLines data - this screen was created using the Multi-Tile with 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 Advanced Application. For this example, we'll be working on the grid on the Shop Staff Company Rejected Companies screen.

    Example 1: Passing out data

    Actionflow Properties

    Bulk Delete Rejected Companies

    In this example, we'll set up an Actionflow to pass out company data.

    Create a new

    delete all companies with a Status of Rejected, along with any associated Orders and Order Lines.

    Image Added

    View Setup

    1. Open the Company Rejected Companies screen
    2. Create an Actionflow on the Delete All button
      1. Name: BulkDeleteRejectedCompanies
    3. Configure the input connection point to
      Insert excerpt
      _actionflow_on_click
      _actionflow_on_click
      nopaneltrue
       from the Actionflow home page
      1. Set a unique name and provide a useful description
    4. When the Actionflow opens, on the toolbar, click Create a
      Insert excerpt
      _propertyaction_settingsview
      _propertyaction_settingsview
      nopaneltrue
    5. In the API section of the properties, enable API End-Point
    6. This allows the Actionflow to receive an incoming API
    7. Enable Allow Anonymous Connections to the Companies data to output the CompanyID of rejected companies only
    8. Connect the input to the View 

    Checkpoint

    Image Added

    Lookup Setup

    Create a lookup to the Orders data to retrieve the orderIDs as an array. The orderID can then be used to bulk delete the orders and orderLines. A lookup is used to pass a large block of data (an array) rather than one record at a time.

    Expand
    titleHow?
    1. Create a 
      Insert excerpt
      _action_
    save
    1. calculate
      _action_
    save
    1. calculate
      nopaneltrue
     your changes

    Setup the Input Connection Point Input Parameters

    Click on the
    1.  to process the lookup Orders data
    2. From the Calculate action, create a lookup the Orders data
      1. Request (Incoming) Mappings: CompanyID
      2. Return (Outgoing) Mappings: Order_ID
    3. Create a filter on the Orders 
      Insert excerpt
      _
    input
    1. action_view
      _action_
    input
    1. view
      nopaneltrue
     Connection Point
  • In the Properties that open, in the Input Parameters section, add the following attributes (the names are case sensitive):
  • NameTypeDescriptionbodyStringprovides the information sent in the body of the API call.contentTypeStringProvides details of the Content TypeheadersStringProvides the information sent in the API call header.urlStringProvides the complete URL that was used to call the API. This can be used to pass parameters to the API.   3.  Insert excerpt_save_savenopaneltrue your changes

    Configure your Actionflow to Return Data

    Create a Insert excerpt_action_view_action_viewnopaneltrue action for the Companies table
  • Add the Output Attributes for the data that the API should return
    1. CompanyID
    2. CompanyName
    3. Industry
  • Add a new Connection of type Output
  • Map the attributes to the output
  • View the Return Data

    Open the Actionflow Insert excerpt_property_settings_property_settingsnopaneltrue and in the API section, view the URL  Insert excerpt2.16 Intermediate Actionflows - Training Exercise2.16 Intermediate Actionflows - Training Exercisenopaneltrue

    Example 2: Passing in parameters

    Actionflow

    In this example, we'll .

    Create
    1.  to only retrieve orders that match the incoming CompanyID
    2. On the Calculate action, create an Output Attribute to process the Order IDs coming from the lookup as structured data

    Checkpoint

    Image Added

    Image Added

    Bulk Delete Action Setup

    1. Create three
      Insert excerpt
      _action_bulk_delete
      _action_bulk_delete
      nopaneltrue
       actions for deleting from the three tables: Companies, Orders and OrderLines
    2. Map the associated ID attribute into the relevant Bulk Delete node

      1. Expand
        titleHow?
        1. Map the following attributes from the Calculate action to the Bulk Delete action specified below:
          1. Delete Companies: CompanyID (from the View)
          2. Delete Orders: OrderID (from the Calculate)
          3. Delete Order Lines: OrderID (from the Calculate)


    3. Set up filters on each node in the Data Retrieval Options section to ensure only records associated with a rejected company are deleted

    Checkpoint

    Image Added

    Image AddedImage Added

    Testing

    1. Return to the Company Rejected Companies screen and lock the screen
    2. Press the Bulk Delete button
    3. Refresh the data in each grid to see the results
    4. Review the Orders and Order Lines data to check there are no orders or order lines with a blank company 
    Excerpt
    nameReinstatingData


    Expand
    titleHow to Reinstate Data

    Reinstating Data

    After testing, you may wish to remove the changes you've made and reinstate your data to use again. Ensure you have downloaded the data from the Learning Centre.

    1. Open the Advanced Actionflow Data Analysis Model
    2. Right-click on a
      Insert excerpt
      _tables
      _tables
      nopaneltrue
       where the data has been changed and select 
      Insert excerpt
      _rollback
      _rollback
      nopaneltrue
      1. Select to Rollback all data
      2. Toggle off Keep Old Recordsets
      3. Click Confirm
    3. To reupload the data in its original form, hover over the table's  
      Insert excerpt
      _file_collector
      _file_collector
      nopaneltrue
       and choose 
      Insert excerpt
      _upload_file
      _upload_file
      nopaneltrue
    4. Select the downloaded file on your PC
      1. Click Upload File
    5. Hover over the connected table and choose 
      Insert excerpt
      _run_analysis
      _run_analysis
      nopaneltrue
    6. Repeat these steps with all tables where the data has been changed and requires reinstating
    7. Once the data is restored for each table, 
      Insert excerpt
      _save_saveModel
      _save_saveModel
      nopaneltrue
       the Analysis Model


    Image Modified