PhixFlow Help
16. Running a Task Plan to Import Data
Create a mechanism to allow users to import a list of businesses. To recap the steps in the video:
Load a Business File
- Create a File Importer called
Import Businesses
. - To configure the file importer, upload this test file: Import_Businesses_1.csv.
- Create a stream called
Import Businesses
and set it to Static to use it for testing. - Run the new stream to import the data.
Link Imported Businesses
- Link the
Import Businesses
stream to theBusinesses
stream. - Create a Sequence to provide a consistent mechanism for populating the business
UID
for both file imports and application updates.- Under the application
Businesses
, find Sequences. - Right-click and select Add Sequence, then set:
- Name:
BusinessUID
- Start Value:
10000
- Block Value:
1
- Name:
- Under the application
- Open the stream configuration form for
Businesses
. - Update the expression for the stream attribute
UID
tonextValue('BusinessUID')
- Update the
Description
expression_NULL
- Update all the other expressions to
in.[attribute name]
- Run the stream to populate the data.
Add a Task Plan to Run the Businesses Stream
- Add a Task Plan called
ImportBusinesses
and remember to enable the task plan! - Add a Task.
- Add the stream
Businesses
to the Analysis Task.
Add a Button to Import Contacts
- Open the
Businesses
dashboard. - Add a new action to the
Businesses
Stream and set:- Name: ImportBusinesses
- Display Name: Import
- Ask for Confirmation: tick
- Confirmation Message:
- "Are you sure you want to run this import?"
- In the Run Task Plan section:
- Run Selected Task Plan: tick
- Add a Task Plan
- Select
ImportBusinesses
- Leave the expression blank. We want to run this task plan every time the button is clicked.
- Select
- Finally drag the new action onto the
Businesses
Grid View on theBusinesses
dashboard.
Make the Action Refresh the View
- Open the configuration form for the grid view
Businesses
. - Open the section Refresh Actions.
- Show the list of streams
- Drag your new action into the list of Refresh Actions.
Change to App Mode and test the Import
button.
Refresh the Test Data and Try Again
In this exercise we will clear the test data using Rollback. There is more detail about rolling back data in the Modelling Concepts course.
Being able to roll back changes to data is very useful when you are working on models in a development system. However, do not use it on a production system.
If you think you need to rollback a production system, please contact PhixFlow support or your PhixFlow project team for guidance.
- Right-click on the stream
Businesses
in the model view and select Rollback Stream. - In the rollback form, set
- Keep Old Stream Sets: untick
- Keep the default values for the other options.
The default is to roll back the changes from the most recent run. In this case, it will roll back the data loaded by the import.
- Confirm the rollback.
- Once this is complete, refresh the data in the application, and you will see the import lines disappear.
Now try your Import
button again.
File Loading
To tie the import process together, we will make the Import
button also load a new file of contacts to import.
- Remove the static flag from the
Import Businesses
stream. - Open the configuration form for the Action
Import Businesses
. - Pin this form.
- Open the File Upload section and set
- File Upload button: tick
- Get the tag value from the file importer.
- From your model view, open details for the file importer.
- Copy the value in the field Tag.
- Go back into the configuration for the custom action
Import Businesses
. - Paste the tag value into the field Tag Expr.
Go into App Mode. This time when you click the Import
button, a file upload form will appear. Select and upload the test file: Import_Businesses_2.csv. You can see the newly imported businesses are immediately loaded into the application.
Update the Existing Add Action to Set the UID from a Sequence
To make sure we have a consistent mechanism for setting the Business UID
, we need to update the Add
button on the Businesses
dashboard to use the sequence, rather than relying on the automated mechanism it is currently using.
- Open the configuration form for the
Businesses
stream.- Add an action and set:
- Name:
AddBusiness
- DisplayName:
AddBusiness
- In the Stream Item Action Rules section:
- Add a new Stream Item Action Rule
- Add a new Stream Item Action and set:
- Name:
AddBusinessAction
- Stream Item Action:
Update
- Filter Type:
Selected Items
- Copy Values By Name: Untick
This is required as you want to set only one value programmatically. - Attributes to Update
- Attribute:
UID
- Expression:
nextValue('BusinessUID')
- Attribute:
- Name:
- Name:
- Save all your changes.
- Add an action and set:
- Open the
Businesses
dashboard. - Apply the new action to the
Add
button on your dashboard.
Next video: 17. Auditing Changes
Please let us know if we could improve this page feedback@phixflow.com