...
- Add a task plan, and within this an analysis task
- Add the stream
Contacts
to the analysis task
Add button to import contacts
- Open the app
Contacts
- Add a new button to the edit form
- Set the name of the button to
Import Contacts
- Set the label of the button to
Import Contacts
We need to create a custom action to add to this button - the custom action will run our new task plan. But we do not need to change any of the other settings on the button, since running the task plan is all we need it to do.
Create action to run task plan
- Open the configuration form for the stream
Contacts
- Create new action:
- Name:
Import Contacts
- Display Name:
Import Contacts
- Open the Run Task Plan section
- Tick Run Selected TaskPlan
- Add a task plan rule - you can do this by pressing the button, but we will drag on a task plan instead:
- Press the button
- In the repository browser, open the application
Contacts
- Find your new task plan
- Drag it into the list of task plan rules
- Leave the expression blank - we want to run this task plan every time the button is pressed
- Name:
Complete configuration of button - add custom action
- Go back into the configuration for the button
Import Contacts
- Associate the custom action
Import Contacts
This completes the configuration.
Try new button
Go into App Mode and try the new button. When pressed, you will see no changes. You could, as in the video, go and check in the Console or in the stream data to see what happened. But you could simply press the refresh button in the app, and you will see the imported rows added.
Make the action a refresh action
- Open the configuration form for the grid view in the
Contacts
app - Open the section Refresh Actions
- Press the to bring up the list of streams
- From the repository browser, open the application
Contacts
, find the streamContacts
, open that to find the actions - Drag your new action into the list of refresh actions
Refresh test data and try again
In this exercise you will refresh 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.
- Right click on the stream
Contacts
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 - this time the imported lines will appear straight away.
File loading
To tie our import process together, we will make the import button also load a new file of contacts to import.
Widget Connector | ||||||
---|---|---|---|---|---|---|
|
Update your app to load a file from the import button. To recap the steps in the video:
- Remove the static flag from the
Import Contacts
stream - Open the configuration form for the custom action
Import Contacts
- Pin this form
- Open the File Upload section
- Tick the File Upload button
- 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 Contacts
- Paste the tag value into the field Tag Expr.
Go into App Mode. This time when you press the Import Contacts
button a file upload form will appear - select the second test file and upload this. You will see the new imported contacts loaded into the app straight away.
Panel |
---|
Next chapter: TODO |