Data import
Imports the collections of a file in Drive into a database, and tells your page with the message import when one is done.
The data-import widget imports the collections of a file in Drive into a database, one collection at a time, and shows the progress.
URL and parameters
The widget is at <site>/widgets/data-import. The parameters every widget takes are in Widgets.
| Parameter | Meaning | Required |
|---|---|---|
source_item_id | The _id of the file that holds the collections. Without it, the user picks one in the widget. | No |
target_item_id | The _id of the database to import into. Without it, the user picks one in the widget. | No |
Messages
| action | Direction | payload |
|---|---|---|
import | widget to your page | { parent }, where parent is the _id of the target database. Sent once per collection, when that collection reaches 100%. |
cancel | widget to your page | None. The user closed the widget. |
This widget does not send ready and does not read post-widget-parameters. It sends error and close-with-error as in Widgets.
Example
embedParams is the common parameters from Widgets.
const params = new URLSearchParams({
...embedParams,
source_item_id: fileId,
target_item_id: databaseId,
})
frame.src = `${site}/widgets/data-import?${params}`
addEventListener('message', (e) => {
if (e.origin !== site || e.data.messageToken !== messageToken) return
if (e.data.action === 'import') refreshTables(e.data.payload.parent)
if (e.data.action === 'cancel') frame.remove()
})Notes
import arrives once per collection, not once per file, and the widget does not close itself. The user can import the next collection until you close the widget.
Data picker
Lets the user pick Records from a table or from the lookup data of a form. The result comes back as the message select with the Records that were picked.
User and group picker
Lets the user pick one or more users. The result comes back as the message select. The widget shows only after it has received post-widget-parameters.