# Form Improvement: Duplicate Check

**URL:** <https://community.fibery.io/t/form-improvement-duplicate-check/4205>\
**Category:** Ideas & Features\
**Created:** [March 30, 2023, 1:11pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205 "2023-03-30T13:11:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccollins](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@ccollins](https://community.fibery.io/u/ccollins)\
**Post date:** [March 30, 2023, 1:11pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/1 "2023-03-30T13:11:04Z")

</div>

Data hygiene is becoming more and more of a priority within my company’s Fibery workspace.

Specifying a specific field for a duplication check within that form’s database would be extremely helpful.

> **For example** : add new contact form with the email as the duplication check. If that email exists within the database already, the form sends an error when trying to submit

@Chr1sG’s [Deduplication template](https://community.fibery.io/t/new-template-deduplication/3291/5) is awesome, but in situations like this is a workaround rather than stopping the duplication before it happens.

---

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [March 30, 2023, 3:33pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/2 "2023-03-30T15:33:21Z")

</div>

Hey @ccollins I ran into this exact problem the other day and was able to write an automation using info from @Chr1sG 's post and [this post](https://community.fibery.io/t/centralized-script-management-for-workspace/3039) from @Matt_Blais .

Automation:

1. The automation triggers for new entities created from a form. I put a hidden checkbox on all of my forms to indicate this.
2. The script checks a single text field (‘SKU’ in my case) to see if there is more than one copy in the DB.
3. If there is, it deletes the new entry and throws an error.

There are a few downsides to this approach.

- Creating → Checking → Deleting is probably not the most efficient way to stop duplicates. I would be better to stop entity creation altogether
- The only way to indicate to the user that a duplicate has been created is to throw an error. Unfortunately if an automation errors more than 3 times it is disabled and has to be manually restarted from the automation page. This [feature](https://community.fibery.io/t/allow-button-script-to-show-a-result-message-which-can-be-copied/4038) could help the situation.

Here is a screenshot and the code snippet:

 ![Deduplication Automation](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/2/21f4032495baf7ab42e3262231cf935d5d265ca9.jpeg)

```auto
const fibery = context.getService('fibery')
const entity_type = args.currentEntities[0].type
// Replace 'Data' with the appropriate space name
const SPACE_NAME = 'Data'

for (const entity of args.currentEntities) {
    // Replace 'findMaterials' with the appropriate GraphQL command for the DB
    // Replace 'sku:' and '.sku" with the appropriate text field name 
    const query = `{findMaterials(sku:{contains: "${entity.sku}"}){id}}`
    const result = await fibery.graphql(SPACE_NAME, query)
    const ids = result.data.findMaterials.length
    if (ids > 1) {
        await fibery.deleteEntity(entity.type, entity.id);
        throw new Error("This material already exist, please check database")
    }
}

```

---

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [March 30, 2023, 3:35pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/3 "2023-03-30T15:35:32Z")

</div>

I would also love some suggestions on this approach if people have better ideas. TBH I’m still learning how to use Fibery scripts.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [March 30, 2023, 6:04pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/4 "2023-03-30T18:04:16Z")

</div>

I do not believe that there is any way to perform a duplication check that does not involve comparing a created entity with entities already in the database, and then making a decision.  
From a technical perspective, Fibery can’t currently know what the values of the entity’s fields are before it has been created.

Theoretically, a form view feature could be developed to perform a field-level search at the time the user is entering data, and then object to a duplicate being entered (in the same way as it can object to empty field values) but I suspect this may be quite technically challenging.  
Furthermore, any duplication check would effectively serve as a backdoor method for someone to brute-force query the database - not all users would want people who are filling forms to know whether an entity with a specific value existed 🤔

Overall, I do not expect this problem will be addressed in the short- to medium-term to be honest.

With that said, I suppose the real question is why is duplication-detection-and-deletion objectionable? Presumably because there is currently no nice way to provide immediate feedback to the user that the entity they believe they are creating is actually going to evaporate a fraction of a second later.

If nothing else, you could always add to the deletion automation a notification to the entity creator that their entity was rejected.  
(but won’t work for anonymous submissions)

---

<div class="post-metadata">

**Author:** ![Tommy\_Hedley](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tommy_hedley/32/6468_2.png) [@Tommy\_Hedley](https://community.fibery.io/u/Tommy_Hedley)\
**Post date:** [March 30, 2023, 6:09pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/5 "2023-03-30T18:09:39Z")

</div>

I hadn’t thought about how the pre-creation check would have to be implemented, I definitely see how there could be problems. I will look into adding creator notifications, thanks @ChrisG !

---

<div class="post-metadata">

**Author:** ![ccollins](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@ccollins](https://community.fibery.io/u/ccollins)\
**Post date:** [March 31, 2023, 1:08pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/6 "2023-03-31T13:08:53Z")

</div>

This is incredibly helpful! Thanks Tommy!

---

<div class="post-metadata">

**Author:** ![tycecycle](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@tycecycle](https://community.fibery.io/u/tycecycle)\
**Post date:** [September 9, 2023, 4:01pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/7 "2023-09-09T16:01:42Z")

</div>

Is there a way that this automation could be executed on a formula field created after form submission? My example: have “first name” and “last name” text fields in a database and upon entity creation, the formula “name” is filled in with a concatenation of first name and last name. I’d like to check for duplicates on “name” formula field.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [September 9, 2023, 4:48pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/8 "2023-09-09T16:48:13Z")

</div>

You can trigger an automation when the formula field is updated (irrespective of the source of the data) which checks for duplication.  
We have a deduplication template that you can refer to for inspiration.

---

<div class="post-metadata">

**Author:** ![mdubakov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/mdubakov/32/10_2.png) [@mdubakov](https://community.fibery.io/u/mdubakov)\
**Post date:** [May 8, 2025, 2:27pm UTC](https://community.fibery.io/t/form-improvement-duplicate-check/4205/9 "2025-05-08T14:27:09Z")

</div>

Unique values for fields released today as experimental

> [@May 8, 2025 / New "this week/..." filters, Unique field values (experimental)](https://community.fibery.io/t/may-8-2025-new-this-week-filters-unique-field-values-experimental/8751):
>
> We are back from the Spring holidays season and can finally release something (many large things are in progress still, including permissions things, Gantt View and AI Smart Agent). New filters: is within past/current/next week/month/quarter/year Now you can filter views by past/current/next week/month/quarter/year. It will make your life a little bit easier, since you will no longer have to update manual filters every week/month/quarter/year. Allow only unique values in a Field (exp…
