Versions Compared

Key

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

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Widget Connector
width900
urlhttps://www.youtube.com/watch?v=9Bl8u2O3CkI&index=18&list=PLbPt6SI1Zhb8CnWh7Gvopto7D6LEwcB9A
height500

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  to configure the file importer, and create .
  3. Create a stream called Import BusinessesMake this stream and set it to  Static to allow use it for testing.
  4. Run the new stream to import the data.

Link Imported Businesses

...

  1. Link the Import businesses Businessesstream to the Businesses the Businesses stream.
  2. Create a Sequence to provide a consistent mechanism for populating the contact UID across import from files and app updates:business UID for both file imports and application updates.
    1. Under the application Businessesapplication Businesses, find Sequences.
    2. Right-click and and select Add SequenceConfigure the sequence, then set:
      • Name: BusinessUID BusinessUID
      • Start Value: 10000 10000
      • Block Value: 1 1
  3. Open the stream configuration form for Businessesfor Businesses.
  4. Update the expression for the stream attribute UID to: nextValue('BusinessUID')attribute UID to nextValue('BusinessUID')
  5. Update the Description expression _NULL
  6. Update all the other expressions to: into in.[attribute name]
  7. Except Description which we can set to _NULL
  8. Run the stream to populate the data.

Add

...

a Task Plan to Run the Businesses Stream

  1. Add a Task Plan, ImportBusinessesDon't forget called ImportBusinesses and remember to enable the task plan!
  2. Add a Task.
  3. Add the stream Businesses to 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 tick
    4. Confirmation Message:
      • "Are you sure you want to run this import?"
    5. In the Run Task Plan section:
      • Run Selected Task Plan: Ticktick
      • Add a Task Plan
        • Select ImportBusinesses
        • Leave the expression blank - we . We want to run this task plan every time the button is pressedclicked.
  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. Bring up Show the list of streams
  4. From the repository browser drag Drag your new action into the list of refresh actionsRefresh Actions.

Change to App Mode and test the Import button.

Refresh

...

the Test Data and Try Again

In this exercise you we will refresh clear the test data using rollbackusing Rollback. This is something you will look at in There is more detail about rolling back data 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.

...

 


Tip

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, untick set
    1. Keep Old Stream Sets
    2. Otherwise, leave the default options - by default these will rollback only the latest run (the data loaded from the import): untick
    3. 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 appapplication, and you will see the import lines disappear.

Now try your import Import button again.

File

...

Loading

To tie our the import process together, we will make the import 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 streamthe Import Businesses stream.
  2. Open the configuration form for the Action Import  Import Businesses.
  3. Pin this form.
  4. Open the File Upload section and set
      Tick the 
      1. File Upload button: tick
    1. Get the tag value  value from the file importer:.
      1. From your model view, open details for the file importer.
      2. Copy the value in the field Tag.
    2. Go back into the configuration for the custom action Import action Import Businesses.
    3. Paste the tag value into the field Tag Expr.

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

    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 contact data 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 Streamstream.
      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
              This is required as you want to set only one value programmaticallyvalue programmatically.
            • Attributes to Update
              • Attribute: UID UID
              • Expression:
               nextValue
              •  nextValue('BusinessUID')
      2. Save all your changes.
    2. Open the Businesses the Businesses dashboard.
    3. Apply the new action to the Add button Add button on your dashboard.


    Panel

    Next video: 17. Auditing Changes