In this chapter we will set up a task plan to import data, from a file, into our app. We will also see how to set up a refresh action, and trigger file loading from a button.
You will need two import files for the exercises. You can download these files here:
Running task plans, refresh actions
Set up a button to run a task plan in your app to import contacts from files. To recap the steps in the video:
Load up contact file
- Create file importer called
Import Contacts
- Load up the test file Contact Import 1.xlsx to configure the file importer, and create a stream
Link imported contacts into contacts stream
- Link the imported contacts stream to the
Contacts
stream - Create a sequence to provide a consistent mechanism for populating the contact UID across import from files and app updates:
- Under the application
Contacts
, find Sequences - Right click and Add Sequence
- Configure the sequence:
- Name:
ContactUID
- Start Value:
10000
- Block Value:
1
- Name:
- Under the application
- Open the stream configuration form for
Contacts
- Update the expression for the stream attribute
UID
to:nextValue('ContactUID')
- Update all other expressions to:
in.[attribute name]
Update actions to set UID from sequence
To make sure we have a consistent mechanism for setting the contact UID, we need to update the actions that update contact data to use the sequence, rather than relying on the automated mechanism they are currently using.
- Open the
Contacts
app - Go into the configuration form for the button
Update
- Click on the quick link to bring up details for the custom action (
Validate Contact
) - Go to the Update StreamItems section
- Add an update rule:
- Attribute:
UID
- Expression:
nextValue('ContactUID')
- Attribute:
- Note: you do not need to update the action attached to the
Add
button, because this uses the same custom action as update
Add task plan to run Contacts stream
- Add a task plan, and within this an analysis task
- Add the stream
Contacts
to the analysis task
Add button