# Imports

## Overview <a href="#overview" id="overview"></a>

The imports register enables data to be imported into Registers and Assets.

System Administrators can [run](https://docs.cw.crisisworks.com/system-administration/reporting/running-reports) imports for [Register Items](#register-items) and [Assets](#assets). The System administrator configures the [settings](#imports-settings) including the [parsing rules](#parsing-rules) and once the import file has been uploaded and saved, can view the [result](#result).

The Import operates using a parser to map the fields to the database and insert them using a **Parsing Rule**. Each Parsing Rule also has a default method of updating the database.

{% hint style="info" %}
It is important to select the correct Parsing Rule for the data you wish to import as your import may otherwise fail. It is also important to make sure that the data is in the correct format, including all of the required columns and that the columns are correctly named, otherwise your import may fail. For a guide on field mappings and expected formats, see [Field Mappings and File Types](https://docs.cw.crisisworks.com/system-administration/configuring-the-system/imports/register-items/contacts-import).
{% endhint %}

#### Import formats <a href="#import-formats" id="import-formats"></a>

Most (but not all) are imported in Comma Separated Value (CSV) format. Some asset imports also accept ZIP files containing other formats.

{% hint style="info" %}
If your import data file is in another format, such as Microsoft Excel, you will need to save or convert it to CSV or the specified file type prior to uploading it.
{% endhint %}

If you're updating or adding to an existing list of items you can also create a CSV file from existing data by exporting register items to a report first using the Export function from the datagrid. Files exported are compatible with the import system.

#### **Clearing Field Data** <a href="#clearing-field-data" id="clearing-field-data"></a>

If column headings or data is not specified in your import file for existing items, the existing data will usually not be removed.

If you wish to remove data for a field of an existing item, set the value "\[NULL]" into the field in your import data. If this value is found in your import data, it will clear the existing value. For example if you wish to clear tags for the userId of "bob", simply type "\[NULL]" in the Tags column of your data on Bob's record and all existing tags for Bob will be removed.

### Access <a href="#access" id="access"></a>

To access the Imports register you will need to sign in with [*System Admin & Data Entry* position](https://docs.cw.crisisworks.com/system-administration/configuring-the-system/..#system-administration-positions).

You can find the *Imports* register under **System Administration** **> Imports**.

### Register Items <a href="#register-items" id="register-items"></a>

Register Items is used to add to or update the respective [registers](https://docs.cw.crisisworks.com/concepts-and-fundamentals/on-a-computer/using-the-datagrid).

Refer to the Register Items import page for more details on this option:

{% content-ref url="imports/register-items" %}
[register-items](https://docs.cw.crisisworks.com/system-administration/configuring-the-system/imports/register-items)
{% endcontent-ref %}

### Assets <a href="#assets" id="assets"></a>

Assets imports are used to add to or update the [Asset database](https://docs.cw.crisisworks.com/concepts-and-fundamentals/concepts-and-fundamentals#register-assets-and-resources). There are no registers for this, they are stored internally and can only be imported or reimported.

Refer to the Assets import page for more details on this option:

{% content-ref url="imports/assets" %}
[assets](https://docs.cw.crisisworks.com/system-administration/configuring-the-system/imports/assets)
{% endcontent-ref %}

### Workflow <a href="#workflow" id="workflow"></a>

Imports use a similar workflow process to the Reports module in that they do not run instantly. They are first Queued, then Run before becoming either Finished or Failed.

| Status    | Icon                                                                                                                                                                                                                                                   | Description                                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| New       | <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FX0CRR5jkOxu7rIzKtYrm%2Fimage.png?alt=media&#x26;token=79205f93-11f0-424e-afe9-d7a3bca24eb4" alt="" data-size="line"> | The Import has been created but has not yet been run. You will rarely see this as most imports run automatically when created. |
| Queued    | <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FVDb1jLEfabqe392Xp3u0%2Fimage.png?alt=media&#x26;token=8f3242ec-7b3f-4762-b155-40e293274bc3" alt="" data-size="line"> | The report is scheduled to run but is waiting for other processes to run first                                                 |
| Running   | <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FAypOaohNWVeSi5LDuv9f%2Fimage.png?alt=media&#x26;token=72dfd6af-e80e-45e7-ba4b-8e226debd511" alt="" data-size="line"> | The Import is in the process of running                                                                                        |
| Finished  | <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2Ff7aYnf8u5Jvaf1XjB1FL%2Fimage.png?alt=media&#x26;token=671e4be4-12a2-496e-a34f-4c23827e4070" alt="" data-size="line"> | Your data has been imported successfully.                                                                                      |
| Failed    | <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2F9I9iyuBxieIUvBi15PgN%2Fimage.png?alt=media&#x26;token=dbc0cd0b-d657-4357-a9e3-b6e47cddcf98" alt="" data-size="line"> | Failed to run. Look at the logs to determine the reason/s. Correct and try again.                                              |
| Cancelled | <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FUPpWvPvczBzcDLR2LdgC%2Fimage.png?alt=media&#x26;token=a39054d9-8630-4eae-bf23-1ab4c55d628b" alt="" data-size="line"> | The import was cancelled while still queued or running.                                                                        |

## Viewing Imports <a href="#viewing-imports" id="viewing-imports"></a>

Imports are listed in and searchable via the register [Datagrid](https://docs.cw.crisisworks.com/concepts-and-fundamentals/on-a-computer/using-the-datagrid#data-grid-view).

{% hint style="info" %}
Imports only stay Active while they are being run. Most imports that have already been run will not show up under Active. Use the Totals filter or one of the Workflow filters (such as Finished) to find these.
{% endhint %}

To view an existing Import:

1. Navigate to the Imports register datagrid.
2. Locate the item you wish to view. The register includes additional filters for Workflow Status (New; Queued; Running; Finished; Failed; Cancelled)
3. Open the item using the ID
4. To return to the Datagrid use the Back button <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FkJtmQ5qacZpOVfkdqfY8%2Fimage.png?alt=media&#x26;token=b4c68b18-dc6e-48bb-8a2e-c14bf3f595be" alt="" data-size="line">

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2F0MtDHdlKr4tS1x4p7rgS%2Fimage.png?alt=media&#x26;token=432d505c-0192-4cd1-80f0-d3499701bd97" alt=""><figcaption><p>View of sample Imports register including the status of imports (finished or failed)</p></figcaption></figure>

## Settings <a href="#settings" id="settings"></a>

| Left Column                       | Right Column                                |
| --------------------------------- | ------------------------------------------- |
| [Record Notes](#record-notes)     | [Workflow](#workflow-1)                     |
| [General](#general)               | [Import Instructions](#import-instructions) |
| [Categorisation](#categorisation) | [Activity](#activity)                       |
| [Advanced](#advanced)             |                                             |
| [Result](#result)                 |                                             |

### Record Notes <a href="#record-notes" id="record-notes"></a>

When editing, record notes in the [rich text field](https://docs.cw.crisisworks.com/concepts-and-fundamentals/on-a-computer/using-the-datagrid/editing-items#rich-text-fields) as you make changes which will appear in the Activity log.

Refer to: [Recording Notes](https://docs.cw.crisisworks.com/concepts-and-fundamentals/on-a-computer/using-the-datagrid/editing-items#recording-notes)

### General <a href="#general" id="general"></a>

#### **Type** <a href="#type" id="type"></a>

These options choose the type of Import. There are currently only two types: Register Items; and Assets.

#### **Parsing Rules** <a href="#parsing-rules" id="parsing-rules"></a>

The **Parsing Rule** setting is used to determine the Register/s the import is being run for and the method for updating the database. Consider this carefully to make sure you're importing your data into the correct register.

The default rule for all imports is *Insert new records, update matching records* (see below). You can override this method using the **Override parser defaults** checkbox.

To override the default and choose a rule for how to handle the import, select a Match Rule.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2F8kflom55PXutuaSSFWOc%2Fimage.png?alt=media&#x26;token=a528dc1f-2a9f-44c1-a247-3c3e30763c24" alt="" width="375"><figcaption><p>Match rule field</p></figcaption></figure>

When your rule involves updating existing items, you'll be required to select a **Record matching strategy** (the exception is when you're not overriding the default rule in which case the system chooses one for you automatically). This can be an External ID, Record ID or Related Asset. This settings helps ensure that the existing items that need updating are properly identified.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2Fzlbbj61mrGQyaxj7BNK7%2Fimage.png?alt=media&#x26;token=9f93c9a3-c47a-4d13-a8e4-b626764d15a6" alt="" width="375"><figcaption><p>Selecting a Record matching strategy to update existing items</p></figcaption></figure>

The following rules are available depending on which parser you've selected (you can only use one):

* **Delete data and replace with import data** - will delete all data in the register prior to importing data from your import file
* **Insert new records, update matching records** - adds records, but also matches existing ones. To update existing items you must select a matching strategy. You can update existing items that are inactive by ticking the *Include active records when matching* box. By default these are ignored\
  ![](https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FUy6oa3GhVPFaW1HPRcM9%2Fimage.png?alt=media\&token=52e34a74-d50f-4e0b-805b-635ae595b06a)
* **Insert Only (do not update matching records)** - adds items to your register without either deleting or updating existing items. Only use this if you are adding new items.
* **Update Only (do not insert non-matching records)** - won't add any new records and only matches existing ones. To update existing items you must select a matching strategy. You can update existing items that are inactive by ticking the *Include active records when matching* box. By default these are ignored.

### Categorisation <a href="#categorisation" id="categorisation"></a>

The Categorisation section gives you the option to associate an event, tag or region to the import.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2Fxt7yL66ybPeUVG6fFNx9%2Fimage.png?alt=media&#x26;token=09f60be9-1cd7-43cd-bb6a-d3fcc388279c" alt="" width="375"><figcaption><p>Categorisation section options</p></figcaption></figure>

#### Event ID <a href="#event-id" id="event-id"></a>

{% hint style="info" %}
Assets don't link to events, therefore if you have selected Assets, the Event ID option will not be available.
{% endhint %}

To import your register items into a specific event, put the ID of the event in this field. You can find the ID in the [Event register](https://docs.cw.crisisworks.com/system-administration/managing-events). Note that if you've already got an Event ID in your import file, that will be used instead.

If you want to specify different events for different items and the Import enables it, use the Event or Event ID in the import file. This will override what is specified here.

#### Tag <a href="#tag" id="tag"></a>

Refer to: [Tagging items](https://docs.cw.crisisworks.com/concepts-and-fundamentals/on-a-computer/using-the-datagrid/tagging-items)

To tag all the items, type your tag name into this field. This is not a standard tag selection field. If you're using an existing tag, you'll need to match its spelling exactly.

#### Region <a href="#region" id="region"></a>

Refer to: [Sites and Regions](https://docs.cw.crisisworks.com/concepts-and-fundamentals/concepts-and-fundamentals#sites-and-regions)

To associate your import with a specific region, select it from the list. Note that if you've already got a region specified in your import file, that will be used instead.

### Advanced <a href="#advanced" id="advanced"></a>

**Test Only** lets you test your import before actually importing your data. To do this, place a tick in the Test Only checkbox. This will run through the import process and attempt to import each line of the import file but it won't actually save the records. Once the test import is complete it will return a status allowing you to view the details of any errors so you can fix up any issues before performing an actual import of your data.

**Rollback on Error** will roll back any changes if any errors with your import is detected. This includes any items where a match didn't succeed. Nothing will be inserted, updated or deleted. Do not use this setting unless necessary for testing or it may prevent your import from running.

**Check that all columns in the input file match known attributes** will analyse the import file and will alert you if there are any issues with your column headings. This option is useful as it will performs two checks:

1. that all required fields for the import type exist in the import file
2. if you have any additional fields in your import file that are not specified for this import type. This can be helpful to look at as it is possible that a field can be misspelt or not have the correct spaces or capitalisation required. If you get an error about the additional fields in your spreadsheet, you can either remove these additional fields from your input file or you can untick this option to ignored them.

**Create separate audit records for each record** will displayed on the Dashboard and audit history log for each item once the import is complete. Leave this field blank if you do not wish to add a comment for audit history. This is a useful option to enable.

**Bypass state machine rules** ignores restrictions that the system places to prevent updates to records where the status moves to an incompatible state. This option is generally not recommended.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2Fdx1KJaE2zz8RHxLD3Phu%2Fimage.png?alt=media&#x26;token=12d32b37-a249-4db5-a5fa-def21a48ee23" alt="" width="375"><figcaption><p>Advanced section</p></figcaption></figure>

### Result <a href="#result" id="result"></a>

The Result section summarises the results of the import (how many records and the status of the import of each row in the file).

### Workflow <a href="#workflow" id="workflow"></a>

**Date Started** and **Date Completed** are filled in automatically by the system.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FLdYbkOrM2THtAy2lQx6o%2Fimage.png?alt=media&#x26;token=7c1d9e62-a4a7-4c03-bae4-10c9a50d5c2e" alt="" width="375"><figcaption><p>Workflow section in Edit mode</p></figcaption></figure>

**Status** registers the current [Workflow](#workflow) state. Unlike other register items you cannot change the Status of an import. This is automatically set to New by the import process.

### Import Instructions <a href="#import-instructions" id="import-instructions"></a>

The Import Instructions section contacts specific instructions.

#### Import Field Mappings <a href="#import-field-mappings" id="import-field-mappings"></a>

The Import Field Mappings section includes a table with instructions on the structure and contents of your import file in order for the import to work as expected.

Your import file must match these settings otherwise the import will fail.

The first column contains the field name. It is essential that your import file columns match these headings exactly. You can use the Copy icon <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2F55bGjPA4JH63P8XsZYcm%2Fimage.png?alt=media&#x26;token=0b7ca5e9-3816-47b0-9651-6e84fa72bdb5" alt="" data-size="line"> to add this to your clipboard to paste.

The Description column includes specific instructions for the data expected in each row.

The Required Field indicates which fields must be present in your import file. These fields will say Yes.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FzGfI55e0zh18E75gzBJ9%2Fimage.png?alt=media&#x26;token=e1b4dd3a-822e-4e2d-a55d-f917c69acf83" alt="" width="375"><figcaption><p>Import Instructions section and Import Field Mappings</p></figcaption></figure>

### Activity

Refer to: [Viewing Items: Activity](https://docs.cw.crisisworks.com/concepts-and-fundamentals/on-a-computer/using-the-datagrid/viewing-items#activity)

## Editing Imports <a href="#editing-imports" id="editing-imports"></a>

Imports can be edited from the datagrid. Editing an import is usually for re-running (resubmitting) it.

1. Navigate to the Imports register
2. Locate the Import you wish to edit by using the Edit button <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FMAt3SdDCVeaavZpkxUrB%2Fimage.png?alt=media&#x26;token=bf8178b8-3a9c-4b0d-9c30-009542c2ad7b" alt="" data-size="line">
3. Make the necessary changes to the [Settings](#imports-settings)
4. Save <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FN4Q1ymwZJ5s252DI8Xac%2Fimage.png?alt=media&#x26;token=ea3758c1-f326-47ba-ac4c-c1460bcfcd0f" alt="" data-size="line">

## Running an Import <a href="#running-an-import" id="running-an-import"></a>

To run an Import:

1. Use the [New Item button](https://docs.cw.crisisworks.com/concepts-and-fundamentals/on-a-computer/using-the-datagrid/adding-items) for New Import <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FmhD0Gm6G17YXfS0628V3%2Fimage.png?alt=media&#x26;token=81b5d404-55ae-4507-a10d-6a3ceb9d90e0" alt="" data-size="line">
2. Select a **Type** and **Parsing Rule** and use the Add File button to **Import File**
3. Make any other configurations changes necessary in the [Settings](#imports-settings)
4. Use the **Save** button <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FWyvhwIZJBvXfK2U8LqPC%2Fimage.png?alt=media&#x26;token=79843521-0f38-4c32-b05b-3fa126a9b4e6" alt="" data-size="line">

This will initiate the workflow process. You can check the datagrid status or the Result section to see whether the import ran successfully.

{% hint style="warning" %}
Note that the imported items may not show up in the register straight away. Depending on the number of records it may take some time for the items to display and for the counters to update. Please be patient once the import has been run.
{% endhint %}
