# Case Import Wizard

{% @arcade/embed flowId="fMgal9TeC6sfaj2xFHpT" url="<https://app.arcade.software/share/fMgal9TeC6sfaj2xFHpT>" %}

{% hint style="danger" %}
This use case has some configuration prerequisites. Make sure you review the [**Set up**](#f1104ea9-b30d-4396-b858-55c41b4cffd1) section of this page before building !
{% endhint %}

{% hint style="success" %}

#### **Learning focus points**

* Import records into Salesforce using the **CSV parser**
* **Lookup identity resolution** using **external Ids**&#x20;
  {% endhint %}

***

## Objective <a href="#id-5f56e1d2-78d8-4f63-af33-0db54f71471a" id="id-5f56e1d2-78d8-4f63-af33-0db54f71471a"></a>

Allow users to easily **create Cases through a custom, no-code import wizard**.&#x20;

Cases are automatically linked to the correct Accounts using readable, user-friendly external IDs, eliminating the need for data loaders and technical expertise.

***

## Solution <a href="#a25298b6-ce1d-426e-8db8-aa41f1cf4fca" id="a25298b6-ce1d-426e-8db8-aa41f1cf4fca"></a>

The solution leverages **Avonni Flow components**.

Service users get a streamlined Data import wizard allowing the to create multiple cases from a CSV file with a few clicks.

### **How It Works (User Perspective)** <a href="#c75990c5-3e25-41fc-89d6-31e1dcfed9ca" id="c75990c5-3e25-41fc-89d6-31e1dcfed9ca"></a>

1. A Service user opens the Case Import Wizard tab, launching the screen flow
2. They are prompted to upload or drop their CSV file containing Cases
3. On the next screen, they review their data for inconsistencies before going further
4. The flow displays Cases ready to be created with their matched Accounts
5. Upon confirming, records are automatically created and the user gets a confirmation screen

### What we'll create <a href="#id-228f54ff-be7f-4ab7-a30a-3582c52d5dfa" id="id-228f54ff-be7f-4ab7-a30a-3582c52d5dfa"></a>

* 2 **custom fields** on the Case and Account objects to hold the Account External Id
* 1 **Screen Flow** to ensure users benefit from a guided workflow
* The flow will use **Avonni flow components** to display content
  * **CSV Parser** : this is a key component use to load and parse data from a CSV, here cases
  * **Data Tables** : used to display data as the process advances ensure full user control
* The flow will use a custom **Avonni Invocable Action** to handle lookup resolution via an External Id field (or any key of your choice)
  * **SObject Collection Get Record** : used to match cases with accounts using an external Id field

***

## Set up <a href="#f1104ea9-b30d-4396-b858-55c41b4cffd1" id="f1104ea9-b30d-4396-b858-55c41b4cffd1"></a>

### **Prerequisites**

* Create 2 custom fields
  * Create a field on the Account object : `ExternalId__c` (External id)
  * Create a field on the Case object : `Account_External_Id__c` (Text)

### **Build the Screen Flow**&#x20;

{% @arcade/embed flowId="XSpITqQ2x2rb1njcAlnf" url="<https://app.arcade.software/share/XSpITqQ2x2rb1njcAlnf>" %}

{% stepper %}
{% step %}

#### Create a screen element with the CSV Parser component

* Drag the CSV parser into the canvas
  * Key fields to match : `Account_External_Id__c`
  * Add other columns as required by your use case
    {% endstep %}

{% step %}

#### Create a second screen element with a Data Table component

* Set the Data source as the output variable of the CSV Parser
* Configure columns as needed
  {% endstep %}

{% step %}

#### Transform Data into Cases

* Use a Transform element to map the output of the CSV Parser with a custom case record collection variable
  * Important : map all the used fields
    {% endstep %}

{% step %}

#### Transform Account External Ids into Text

* Use a second Transform element to map the `Account_External_Id__c` field from the records from the CSV parser's output to a text collection variable
  {% endstep %}

{% step %}

#### Retrieve your Salesforce Accounts

* Use a Get records to query all accounts whose Id is in the transformed text collection
  {% endstep %}

{% step %}

#### Loop on Case records

* Use the SObject Collection Get Record to match Cases with Accounts
  * Source collection : Accounts
  * Operation : FIND
  * Search field Api Name : `ExternalId__c` (Api name on the Account object)
  * Search value : current case's `Account_External_Id__c` ( {!Loop\_Cases.Account\_External\_Id\_\_c} )
* Assign Account to current loop case record
* Assign current case record to a new Case record collection variable
  {% endstep %}

{% step %}

#### Display Cases in a Data Table

* Create a screen with a Data Table to allow users to review the records ready to be created
  * Use the new Case record collection variable as a data source
  * Display other fields as needed
  * Make columns editable so that users can act on fields as required
    {% endstep %}

{% step %}

#### Assign and create Case records

* Use an assignment element to populate a record collection with the previous Data table's cases
  * Create a Case collection variable : `vCasesToCreate`
  * Assign the Data table's `recordsSObjectWithoutKeyField` output

{% hint style="danger" %}
This allows your users' changes to be taken into account during record creation.
{% endhint %}

* Use a Create records to create all cases in the new Cases record variable<br>
  {% endstep %}

{% step %}

#### Add additional screens

* Add other screens or standard Salesforce elements as your use case requires
  {% endstep %}

{% step %}

#### Save and review

* Add the screen flow to your selected lightning page and make it available to users.
  {% endstep %}
  {% endstepper %}

***

## Going further

{% content-ref url="/spaces/1FUd4apB9YHgCEMUFbVb/pages/FpPsVmr1MzkEzur1Rih7" %}
[CSV Parser](/flow/flow-components/csv-parser.md)
{% endcontent-ref %}

{% content-ref url="/spaces/1FUd4apB9YHgCEMUFbVb/pages/ChlfXTiEVXDBHQg2I7fC" %}
[Data Table](/flow/flow-components/data-table.md)
{% endcontent-ref %}

{% content-ref url="/spaces/1FUd4apB9YHgCEMUFbVb/pages/eqc1m7ZICt57uphC4CkI" %}
[Progress Indicator](/flow/flow-components/progress-indicator.md)
{% endcontent-ref %}

{% content-ref url="/spaces/1FUd4apB9YHgCEMUFbVb/pages/5Tda5D7Z4XJIab3xlBUw" %}
[Header](/flow/flow-components/header.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.avonnicomponents.com/projects/use-cases/case-import-wizard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
