Create an Widget Connector width 900 url https://www.youtube.com/watch?v=9Bl8u2O3CkI&index=18&list=PLbPt6SI1Zhb8CnWh7Gvopto7D6LEwcB9A height 500
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
. - Load up the To configure the file importer, upload this test file: Import_Businesses_1.csv to configure the file importer, and create .
- Create a stream called
Import Businesses
Make this stream and set it to Static to allow 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 app application updates:.- Under the application
Businesses
, find Sequences. - Right-click and and select Add SequenceConfigure the 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
to: tonextValue('BusinessUID')
- Update the
Description
expression_NULL
- Update all the other expressions to: to
in.[attribute name]
- Except
Description
which we can set to_NULL
Run the stream to populate the data.
Add a
...
Task Plan to
...
Run the Businesses
...
Stream
- Add a Task Plan, ImportBusinessesDon't forget called
ImportBusinesses
and remember to enable the task plan! - Add a Task.
- Add the stream Businesses to 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 tick
- Confirmation Message:
- "Are you sure you want to run this import?"
- 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.
- 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.
- Bring up Show the list of streams
- drag 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 you we will clear the test data using 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. |
- Right-click on the stream
Businesses
in the model view , and select Rollback Stream. - In the rollback form, untick set
- Keep Old Stream Sets: untick
- Otherwise, leave Keep the default options - by default these will rollback only the latest run (the data loaded from the import)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 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.
- 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 press 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 newly imported businesses are immediately loaded into the app straightapplication.
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
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.
Panel |
---|
Next video: 17. Auditing Changes |