...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Create an mechanism to allow users to import a list of businesses. To recap the steps in the video:
Create an mechanism to allow users to import a list of businesses. To recap the steps in the video:
...
Load business file
- Create File Importer called Import called
Import Businesses
- Load up the test file: Import_Businesses_1.csv to configure the file importer, and create a stream
Import Businesses
- Make this stream Static to allow for testing
- Run the new stream to import the data
Link Imported Businesses into stream
- Link the
Import
businessesBusinesses
stream to the Businesses theBusinesses
stream - Create a Sequence to provide a consistent mechanism for populating the contact UID across import from files business
UID
for both file imports and app updates:- Under the application Businessesapplication
Businesses
, find Sequences - Right click and Add Sequence
- Configure the sequence:
- Name: BusinessUID
BusinessUID
- Start Value: 10000
10000
- Block Value: 1
1
- Name: BusinessUID
- Under the application Businessesapplication
- Open the stream configuration form for Businessesfor
Businesses
- Update the expression for the stream attribute UID to: nextValueattribute
UID
to:nextValue('BusinessUID')
- Update all other expressions to: in
in.[attribute name]
- Except
Description
which we can set to_NULL
- Except
- Run the stream to populate the data
Add a task plan to run the Businesses stream
- Add a Task Plan, ImportBusinesses
- Don't forget 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
- 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 pressed
- Finally drag the new action onto Businesses Grid View on the Businesses dashboard.
Make the action refresh the View
...
...
- Open the configuration form for the grid view
Businesses
- Open the section Refresh Actions
- Bring up the list of streams
- From the repository browser drag your new action into the list of refresh actionsRefresh Actions
Change to App Mode and test the Import button.
Refresh test data and try again
In this exercise you will refresh clear the test data using rollbackusing 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.
- Right click on the stream Businesses in stream
Businesses
in the model view, select Rollback Stream - In the rollback form, untick Keep Old Stream Sets
- Otherwise, leave the default options - by default these will rollback only the latest run (the data loaded from the import)
- Confirm the rollback
- 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.
- Remove the static flag from the Import Businesses the
Import Businesses
stream - Open the configuration form for the Action Import
Import Businesses
- Pin this form
- Open the File Upload section
- Tick the File Upload button
- Get the tag value 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 action
Import Businesses
- Paste the tag value into the field Tag Expr.
Go into App Mode. This time when you press the Import the Import
button, a file upload form will appear - select the test file: Import_Businesses_2.csv and and upload it. You will see the new newly imported contacts businesses loaded into the app straight away.
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 contact data 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
Streamstream- 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 programmaticallyvalue programmatically
- Attributes to Update
- Attribute: UID
UID
- Expression:
-
nextValue('BusinessUID')
- Attribute: UID
- Name:
- Name:
- Save all your changes
- Add an action:
- Open the Businesses the
Businesses
dashboard - Apply the new action to the Add button
Add
button on your dashboard