What is
an API End Point?a Bulk Delete Action?
Image Added
The
Insert excerpt |
---|
| PhixFlow Incoming API | PhixFlow Incoming API | name | API_end_point_action_bulkdelete |
---|
| _action_bulkdelete |
---|
nopanel | true |
---|
|
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 |
---|
name | TablePeriod |
---|
nopanel | true |
---|
|
from the Actionflow home pageSet a unique name and provide a useful descriptionWhen the Actionflow opens, on the toolbar click For the full list of Bulk Delete Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
In the API section of the properties, enable API End-Point- This allows the Actionflow to receive an incoming API
Enable Allow Anonymous Connections Excerpt |
---|
name | AllowAnonymousConnections |
---|
|
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.
save
save
your changesIncoming APIs require a specific set of Input Parameters on the connection point.
Click on the vs
input
inputaction_bulk_delete | nopanel | true |
---|
|
Connection PointIn the Properties that open, in the Input Parameters section, add the following attributes (the names are case sensitive):Name | Type | Description |
---|
body | String | provides the information sent in the body of the API call. |
contentType | String | Provides details of the Content Type |
headers | String | Provides the information sent in the API call header. |
url | String | Provides the complete URL that was used to call the API. This can be used to pass parameters to the API. |
3. Insert excerpt |
---|
_save | _save | nopanel | true |
your changesConfigure the Actionflow to perform the required tasks.
If you wish to return data from the API:
- Add a new Connection of type Output
- 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.
- 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
- HTTP Method
- To call a PhixFlow API use the HTTP Method GET or POST:
- GET simply calls the API with data passed in the body of the request.
- 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.
- API Mode
- 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.
- 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 |
---|
|
The structure of the URL is as follows:
https://<<Server Name>>/phixflow/api/1/action/<<Application Name>>/<<Actionflow Name>>/trigger
parameter | description |
---|
<<Server Name>> | URL of the server e.g. app.phixflow.com |
phixflow | the 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)
- If calling a PhixFlow Asynchronous API only, a result will be immediately returned which includes a Process ID for that run.
- The Process ID is returned on the path:
$.processId
- This can be accessed in an Output attribute using,
_result.value
- The Process ID can be used to call the following URL which will return the current state of the run:
- 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_settings | nopanel | true |
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 | _save | nopanel | true |
the changesStep 8 - Create an Authentication User
In the Insert excerpt |
---|
_repository | _repository | nopanel | true |
, expand the application with the Incoming API.Expand Insert excerpt |
---|
_roles | _roles | nopanel | true |
and create an New Role by clicking Insert excerpt |
---|
_addIcon | _addIcon | nopanel | true |
.Pin the tab as we will need it to remain open.Provide a useful Name e.g. GenerateTokenIn the Privileges section, click Insert excerpt |
---|
_privilege | _privilege | nopanel | true |
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 | _save | nopanel | true |
the changesIn the Insert excerpt |
---|
_user_group | _user_group | nopanel | true |
section, click Insert excerpt |
---|
_user_group | _user_group | nopanel | true |
Add 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.- To create a user see Managing User Accounts → Creating Users.
Click Insert excerpt |
---|
_save | _save | nopanel | true |
and close the tab.Now drag the new user group into the Insert excerpt |
---|
_user_group | _user_group | nopanel | true |
section of the new privilege. Insert excerpt |
---|
_save | _save | nopanel | true |
the changesThe setup should look similar to:- 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 ActionflowYou 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 changeIn the Insert excerpt |
---|
_repository | _repository | nopanel | true |
, scroll down to the Full Repository section and expand itExpand the Insert excerpt |
---|
_user | _user | nopanel | true |
sectionDouble click on the user who will run the Incoming APIClick the 3-dot more menu in the top right of the user propertiesClick Generate API KeyCopy the value displayed and store it somewhere safeStep 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 | _console | nopanel | true |
:If you are making the call using PhixFlow the Responses can be access as follows:
- Click the Actionflow entry
- Image Removed
- In the Messages section which is opened below, double-click the lines that begin Response
- Image Removed
- 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 | _console | nopanel | true |
:- Click the Actionflow entry for the API End-Point
- In the Messages section which is opened below, double-click any of the Messages to see more details
- 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 |
---|
nopanel | true |
---|
|
and Insert excerpt |
---|
| _action_bulk_delete |
---|
| _action_bulk_delete |
---|
nopanel | true |
---|
|
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
- Click the
Insert excerpt |
---|
| _action_bulkdelete |
---|
| _action_bulkdelete |
---|
nopanel | true |
---|
|
icon in the Actionflow toolbar to display any existing tables in the application - Existing tables can be dragged from the Repository onto the canvas, then choose
Insert excerpt |
---|
| _action_bulkdelete |
---|
| _action_bulkdelete |
---|
nopanel | true |
---|
|
to create a Bulk Delete node
- Alternatively, drag the
Insert excerpt |
---|
| _action_bulkdelete |
---|
| _action_bulkdelete |
---|
nopanel | true |
---|
|
icon from the toolbar onto the canvas - In the Create Bulk Delete Action window:
- Enter a Name
- Choose a Type from:
- Delete: allows only records satisfying the specified filter criteria to be deleted
- Set the filter criteria in the Bulk Delete Action
Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
under Data Retrieval Options - see section below
- Delete All: deletes all data from the selected table
- Choose to Allow Audited Table to display tables with Audit Manual Changes enabled in the Table drop down
- By default, tables with Audit Manual Changes enabled are not shown in the Table drop down list
- Choose the Table from the drop down where the records will be deleted
- Or click the table icon to display tables in the Repository
- 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 |
---|
nopanel | true |
---|
|
action, the Data Retrieval Options section shows in the Insert excerpt |
---|
| _property_settings |
---|
| _property_settings |
---|
nopanel | true |
---|
|
. This filter must be set for the Bulk Delete action to run.Image Added
- Choose a Data Range from:
- Latest: selects data from the latest recordsets
- All: selects data from all recordsets (default)
- Set the Filter Criteria to specify which records will be selected for deletion. See Filter → Filter Details
- 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 |
---|
|
Specify Delete Batch SizeWhere the Type is set to Delete on the Insert excerpt |
---|
| _action_bulkdelete |
---|
| _action_bulkdelete |
---|
nopanel | true |
---|
| 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 Tuning → Delete 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 |
---|
|
Insert excerpt |
---|
| Bulk Delete Action Properties |
---|
| Bulk Delete Action Properties |
---|
nopanel | true |
---|
|
|
Worked Example
Here's a worked example using the Company Data (available from the Learning Centre).
In this example, we are using:
- A 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
- Open the Company Rejected Companies screen
- Create an Actionflow on the Delete All button
- Name:
BulkDeleteRejectedCompanies
- Configure the input connection point to
Insert excerpt |
---|
| _actionflow_on_click |
---|
| _actionflow_on_click |
---|
nopanel | true |
---|
|
from the Actionflow home page- Set a unique name and provide a useful description
- When the Actionflow opens, on the toolbar, click Create a
Insert excerpt |
---|
| _propertyaction_settingsview |
---|
| _propertyaction_settingsview |
---|
nopanel | true |
---|
|
- In the API section of the properties, enable API End-Point
- This allows the Actionflow to receive an incoming API
- Enable Allow Anonymous Connections to the Companies data to output the CompanyID of rejected companies only
- Connect the input to the View
Checkpoint
Image AddedLookup 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.
savesave your changesClick on the - to process the lookup Orders data
- From the Calculate action, create a lookup the Orders data
- Request (Incoming) Mappings:
CompanyID - Return (Outgoing) Mappings:
Order_ID
- Create a filter on the Orders
|
inputinput Connection PointIn the Properties that open, in the Input Parameters section, add the following attributes (the names are case sensitive):Name | Type | Description |
---|
body | String | provides the information sent in the body of the API call. |
contentType | String | Provides details of the Content Type |
headers | String | Provides the information sent in the API call header. |
url | String | Provides the complete URL that was used to call the API. This can be used to pass parameters to the API. |
3. Insert excerpt |
---|
_save | _save | nopanel | true |
your changesCreate a Insert excerpt |
---|
_action_view | _action_view | nopanel | true |
action for the Companies tableAdd the Output Attributes for the data that the API should return- CompanyID
- CompanyName
- Industry
Add a new Connection of type OutputMap the attributes to the outputView the Return Data
Open the Actionflow Insert excerpt |
---|
_property_settings | _property_settings | nopanel | true |
and in the API section, view the URL Insert excerpt |
---|
2.16 Intermediate Actionflows - Training Exercise | 2.16 Intermediate Actionflows - Training Exercise | nopanel | true |
---|
Example 2: Passing in parameters
Actionflow
In this example, we'll .
Create- to only retrieve orders that match the incoming CompanyID
- On the Calculate action, create an Output Attribute to process the Order IDs coming from the lookup as structured data
|
Checkpoint
Image Added
Image AddedBulk Delete Action Setup
- Create three
Insert excerpt |
---|
| _action_bulk_delete |
---|
| _action_bulk_delete |
---|
nopanel | true |
---|
|
actions for deleting from the three tables: Companies, Orders and OrderLines - Map the associated ID attribute into the relevant Bulk Delete node
Expand |
---|
|
- Map the following attributes from the Calculate action to the Bulk Delete action specified below:
- Delete Companies:
CompanyID (from the View) - Delete Orders:
OrderID (from the Calculate) - Delete Order Lines:
OrderID (from the Calculate)
|
- 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
- Return to the Company Rejected Companies screen and lock the screen
- Press the Bulk Delete button
- Refresh the data in each grid to see the results
- Review the Orders and Order Lines data to check there are no orders or order lines with a blank company
Excerpt |
---|
|
Expand |
---|
title | How to Reinstate Data |
---|
| Reinstating DataAfter 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. - Open the Advanced Actionflow Data Analysis Model
- Right-click on a
Insert excerpt |
---|
| _tables |
---|
| _tables |
---|
nopanel | true |
---|
| where the data has been changed and select Insert excerpt |
---|
| _rollback |
---|
| _rollback |
---|
nopanel | true |
---|
|
- Select to Rollback all data
- Toggle off Keep Old Recordsets
- Click Confirm
- To reupload the data in its original form, hover over the table's
Insert excerpt |
---|
| _file_collector |
---|
| _file_collector |
---|
nopanel | true |
---|
| and choose Insert excerpt |
---|
| _upload_file |
---|
| _upload_file |
---|
nopanel | true |
---|
|
- Select the downloaded file on your PC
- Click Upload File
- Hover over the connected table and choose
Insert excerpt |
---|
| _run_analysis |
---|
| _run_analysis |
---|
nopanel | true |
---|
|
- Repeat these steps with all tables where the data has been changed and requires reinstating
- Once the data is restored for each table,
Insert excerpt |
---|
| _save_saveModel |
---|
| _save_saveModel |
---|
nopanel | true |
---|
| the Analysis Model
|
|
Image Modified