# Prevent Duplicates While Creating or Updating Records using Workflow

Suppose you are setting up a workflow for generating **“New Account”** records and you want to find if there are duplicate account records existing in your CRM system. Then, no worries, you can find duplicates using our action in workflow.

Here we’re going to execute duplicate detection from Workflow. For the current scenario, we’re using an on-demand workflow, but we can execute or trigger the same for all triggering stages of the workflow.

* Navigate to **Advanced Settings --> Processes --> New Process --> Fill the fields -->** Click on **OK**.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FR52Nowb33ZTnBB58Rqiy%2Ffaq%201.png?alt=media&#x26;token=9c06d21b-e573-4226-b592-e9b6f34a7f14" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* **Scope:** Select **‘Organization’.**
* Check on **‘As an on-demand process’.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FJIFedwQAXlu4eMUug2Os%2Ffaq%202.png?alt=media&#x26;token=cde98ade-03c1-4ecf-aa72-dcd60e582e93" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Click on ‘**Add Step’** and select **‘Perform Action’.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FQPY32dplc0lOPVflV9ba%2Ffaq%203.png?alt=media&#x26;token=8576ccbf-eb44-461c-9c6e-05cfb8e5f58c" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* **Action:** Select **“InogicDeDupeDGetDuplicateRecordsCount”** action.
* **Entity:** Select **“None (global)”.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F7W8mcooiwoGV2NWtHZs3%2Ffaq%204.png?alt=media&#x26;token=5982ebce-c11d-49a2-9a21-70e64434b307" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Click on **‘Set Properties’.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FB8zuKiMlpTU2CMeEzDah%2Ffaq%205.png?alt=media&#x26;token=b83f10c0-f2dd-43ab-acbd-08d5f2323a71" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Fill in the details inside or input parameters, which will then be captured by Action.
  * **PrimaryEntityDetails:** Here we’re passing the values of PrimaryEntityDetails in json format,

    Ex: {"Attributes":{"name":"Parker"},"EntityId":"","PrimaryIdAttribute":"accountid"}
  * **PrimaryEntityName:** Account
  * **MatchingEntityName:** Account
* Click on **‘Save and Close’.**

{% hint style="info" %}
**Note: While creating a record, EntityId should be empty and while updating a record, EntityId should be the record ID that is being updated!**
{% endhint %}

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2Fz0iLgo1B04L5uuDCsfZP%2Fimgpsh_fullsize_anim.png?alt=media&#x26;token=7db20c60-1876-4b01-b2e2-a3760e2c2864" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Click on **‘Add Step’** and **‘Check Condition’.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FUQa3yTxoXv5wDDfEDbPm%2Ffaq%207.png?alt=media&#x26;token=43efcab3-3a93-4195-84cf-d6abf42ca0a6" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Here, we will check the condition whether the duplicate record count is equal to 0. Similarly, you can define any condition.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F1fBUdYwc6kbjDCADvlhm%2Ffaq%208.png?alt=media&#x26;token=c7b3e4f3-1410-4ff1-8e0e-6a3b44af273d" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Click on **‘Save and Close’.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2Fol3qu23MF7hBHEcJXWK6%2Ffaq%209.png?alt=media&#x26;token=63d1034a-d8aa-437b-b8de-a4b9206f10e2" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FgHaV0kjcxTIrlmbIOd1D%2Ffaq%2010.png?alt=media&#x26;token=42f1b0da-928a-4ae9-81e6-e87d7faa3a3b" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Add another step under the above-added step and select **‘Create Record’.**

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2F3HqMLyXyMOioZ2dAscET%2Ffaq%2011.png?alt=media&#x26;token=d112572f-c5d4-488a-a576-08a1346b976e" alt="Creating or Updating Records using Workflow"><figcaption></figcaption></figure>

* Now the workflow will run and create a new account record since no duplicate records are found inside the account entity.

<figure><img src="https://272130504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M0QoyqUVI8_HaZ9FOSL%2Fuploads%2FOdY6QbwM0TSbhtQpCXVp%2Ffaq%2012.png?alt=media&#x26;token=7af8616c-795b-4fa8-910e-3237aa5d36a4" alt=""><figcaption></figcaption></figure>
