# Reference an existing Podio item on Create New

There are instances where a Customer record already exists in Podio and we do not want to create duplicates. This can be achieved with **Workflow Automation**.

When we receive a new website request, we supply the Lead with a Quote. Once this Quote is accepted and new Project is created and the Lead becomes a Customer. We want to reference the Customer record to this newly created **Project** item.

## The Solution to Duplicates

Solving this problem is possible with **Workflow Automation** using the **Search for Item(s)** and a **Sanity Check** actions. This solution will take 3 flows to complete:

* a first for when the Customer exists,
* a second for when the Customer needs to be created and
* a third to add the new Customer item to the referenced **Project** item.

1. **First**, we need to modify the **Customer template** by adding a **Relationship** field and call it **Temp Link**. Choose your trigger app for reference to. For example, here we chose the **Project** app.

   ![Solution to Duplicate item](https://www.progress.com/podio/documentation/assets/2cda384715d8771490466c77b85b4086/exstng-itm-sol1.png)

   ![Solution to Duplicate item](https://www.progress.com/podio/documentation/assets/b0d2ad509fd73ec7571bcb3511747bf0/exstng-itm-sol1a.png)

   * This field is required when a new item is created in the Customer app by **Workflow Automation**. Be sure to do a Refresh from Podio in your **Workflow Automation** account to sync the changes.

     ![Solution to Duplicate item](https://www.progress.com/podio/documentation/assets/ef83a3eae3e998aab37e4203fd2a2614/exstng-itm-sol1b.png)

2. The **first flow** to create is one to add the Customer item to the Project item when the client already exists.

   * **First**, Add a New Flow and select how to trigger. For this example, we are triggering when a new item is created in Projects. Leave the filters blank as we want this to run on every new item.

   * **Next**, add the **Get Referenced Item** action to collect the **Lead** data. Then add the **Search for Item(s)** action and set up to the Customer app.

   * Using a single line text field called **Email Address**, we are searching for items in the Customer app that have the same email address as the item in the Lead app.

   * Add the **Sanity Check** and create an expression to check the found Customer items **Podio ID** and if it is not empty.

   * Then add the **Update Item** action to update the relationship field on the **Project** with the found Customer record.

     ![Solution to Duplicate item](https://www.progress.com/podio/documentation/assets/51b109aefdb82614b7f81b19e0479cce/exstng-itm-sol1c.png)

3. The **second flow** to create is creating the Customer item when the client does not exist.

   * Again, add a **New Flow** and trigger on creation of **New Project**. No filters are required so this runs on all items.

   * Just like above, add the **Get Referenced Items**, the **Search for Items** and **Sanity Check**, only this time the **Sanity Check** will check that the **Podio Item ID** is empty.

   * Then add the Create Item action and create a new item in the Customers app. Be sure to set up the Temp Link relationship field to the Current Project Item.

     ![Solution to Duplicate item](https://www.progress.com/podio/documentation/assets/806a1e16d06f17f2811355fb1e4d0061/exstng-itm-sol1d.png)

4. The **third flow** will run in the **Customer app** on creation of new items to complete the link from the **Project** record.

   * Add a **New Flow** to run on creation of new items and a filter to check that the Temp Link field is not empty.

   * Add an action to **Update Referenced** to update the **Project** record with the current **Customer Item**.

     ![Solution to Duplicate item](https://www.progress.com/podio/documentation/assets/2e7533c92062d6166f64dc023e53fc53/exstng-itm-sol1e.png)

## The Result

When a new Project Item is created, Workflow Automation searches for an existing Customer record that contains the same email as the referenced Lead item.

If a Customer record has been found, this record is added to the Project. If one is not found, the Customer item is created and then linked to the Project.
