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

  1. Create a File Importer called Import Businesses.
  2. To configure the file importer, upload this test file: Import_Businesses_1.csv.
  3. Create a stream called Import Businesses and set it to  Static to use it for testing.
  4. Run the new stream to import the data.

Link Imported Businesses

  1. Link the Import Businesses stream to the Businesses stream.
  2. Create a Sequence to provide a consistent mechanism for populating the business UID for both file imports and application updates.
    1. Under the application Businesses, find Sequences.
    2. Right-click and select Add Sequence, then set:
      • NameBusinessUID
      • Start Value10000
      • Block Value1
  3. Open the stream configuration form for Businesses.
  4. Update the expression for the stream attribute UID to nextValue('BusinessUID')
  5. Update the Description expression _NULL
  6. Update all the other expressions to in.[attribute name]
  7. Run the stream to populate the data.

Add a Task Plan to Run the Businesses Stream

  1. Add a Task Plan called ImportBusinesses and remember to enable the task plan!
  2. Add a Task.
  3. Add the stream Businesses to the Analysis Task.

Add a Button to Import Contacts

  1. Open the Businesses dashboard.
  2. Add a new action to the Businesses Stream and set:
    1. Name: ImportBusinesses
    2. Display Name: Import
    3. Ask for Confirmation: tick
    4. Confirmation Message:
      • "Are you sure you want to run this import?"
    5. 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.
  3. Finally drag the new action onto the Businesses Grid View on the Businesses dashboard.

Make the Action Refresh the View

  1. Open the configuration form for the grid view Businesses.
  2. Open the section Refresh Actions.
  3. Show the list of streams
  4. 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.

  1. Right-click on the stream Businesses in the model view and select Rollback Stream.
  2. In the rollback form, set
    1. Keep Old Stream Sets: untick
    2. 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.
  3. Confirm the rollback.
  4. 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.

  1. Remove the static flag from the Import Businesses stream.
  2. Open the configuration form for the Action Import Businesses.
  3. Pin this form.
  4. Open the File Upload section and set
    1. File Upload button: tick
  5. Get the tag value from the file importer.
    1. From your model view, open details for the file importer.
    2. Copy the value in the field Tag.
  6. Go back into the configuration for the custom action Import Businesses.
  7. 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.

  1. Open the configuration form for the Businesses stream.
    1. 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
            • AttributeUID
            • ExpressionnextValue('BusinessUID')
    2. Save all your changes.
  2. Open the Businesses dashboard.
  3. 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