Versions Compared

Key

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

Create an mechanism to allow users to import a list of businesses. To recap the steps in the video:

Load business file

  1. Create File Importer called Import Businesses
  2. Load up the test file: Import_Businesses_1.csv to configure the file importer, and create a stream Import Businesses
    1. Make this stream Static to allow for testing
  3. 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 app updates:
    1. Under the application Businesses, find Sequences
    2. Right click and Add Sequence
    3. Configure the sequence:
      • 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 all other expressions to: in.[attribute name]
    1. Except Description which we can set to _NULL
  6. Run the stream to populate the data

Add a task plan to run the Businesses stream

  1. Add a Task Plan, ImportBusinesses
    1. Don't forget 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
    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 pressed
  3. Finally drag the new action onto 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. Bring up 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 test data and try again

In this exercise you will clear the test data using Rollback. This is something you will look at in more detail in the Modelling Concepts course. Just note that this is a very useful thing while developing models, but should not be used in production systems - at least not without guidance from a PhixFlow project team or PhixFlow support.

  1. Right click on the stream Businesses in the model view, select Rollback Stream
  2. In the rollback form, untick Keep Old Stream Sets
    1. Otherwise, leave the default options - by default these will rollback only the latest run (the data loaded from the import)
  3. Confirm the rollback
  4. Once this is complete, refresh the data in the app, and you will see the import lines disappear

Now try your import button again

File loading

To tie our import process together, we will make the import button also load a new file of contacts to import. Update your app to load a file from the import button.

  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
  5. Tick the File Upload button
  6. 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
  7. Go back into the configuration for the custom action Import Businesses
  8. Paste the tag value into the field Tag Expr.

Go into App Mode. This time when you press the Import button, a file upload form will appear - select the test file: Import_Businesses_2.csv and upload it. You will see the newly imported businesses loaded into the app straight.

Update existing Add action to set UID from 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:
      • Name: AddBusiness
      • DisplayName: AddBusiness
      • In the Stream Item Action Rules section
        • Add a new Stream Item Action Rule
        • Add a new Stream Item Action
          • 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