# Flow to control duplicate records

**URL:** <https://community.directus.com/t/flow-to-control-duplicate-records/1529>\
**Category:** Help\
**Tags:** data-modeling, flows\
**Created:** [November 16, 2025, 2:52pm UTC](https://community.directus.com/t/flow-to-control-duplicate-records/1529 "2025-11-16T14:52:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alilo\_Dris](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/alilo_dris/32/746_2.png) [@Alilo\_Dris](https://community.directus.com/u/Alilo_Dris)\
**Post date:** [November 16, 2025, 2:52pm UTC](https://community.directus.com/t/flow-to-control-duplicate-records/1529/1 "2025-11-16T14:52:57Z")

</div>

Hi everyone  
I created a flow to control duplicate records, and I implemented the following configuration:

**1. Read Data Operation:**

```auto
{
    "filter": {
        "_and": [
            { "Ense": { "_eq": "{{ $trigger.payload.Ense }}" } },
            { "activite": { "_eq": "{{ $trigger.payload.activite }}" } },
            { "date_cours": { "_eq": "{{ $trigger.payload.date_cours }}" } }
        ]
    }
}

```

**2. Add Script Operation:(check\_dup)**

```auto
module.exports = async function(data) {
    return (data.read_data.length > 0);
}

```

This script returns `true` if a duplicate exists.

**3. Condition Operation:**

```auto
{
    "check_dup": {
        "_eq": true
    }
}

```

* * *

**The issue:**

Even when there is _no_ duplicate, Directus still returns this error:

```auto
The following fields contain invalid values:
check_dup: The value must be true

```

It seems that Directus is requiring the value `true` even when the condition should evaluate to false (i.e., no duplicates found).

* * *

**Question:**

How can I properly set up the flow so that Directus only triggers the error when a duplicate exists, and allows the record to be created when there is no duplicate?  
thank in advance

---

<div class="post-metadata">

**Author:** ![Alilo\_Dris](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/alilo_dris/32/746_2.png) [@Alilo\_Dris](https://community.directus.com/u/Alilo_Dris)\
**Post date:** [November 19, 2025, 9:35am UTC](https://community.directus.com/t/flow-to-control-duplicate-records/1529/2 "2025-11-19T09:35:58Z")

</div>

YES it’s the name of node add script operation

---

<div class="post-metadata">

**Author:** ![Alilo\_Dris](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/alilo_dris/32/746_2.png) [@Alilo\_Dris](https://community.directus.com/u/Alilo_Dris)\
**Post date:** [November 23, 2025, 10:41am UTC](https://community.directus.com/t/flow-to-control-duplicate-records/1529/3 "2025-11-23T10:41:52Z")

</div>

> [@Alilo\_Dris](#):
>
> ```auto
> {
> "check_dup": {
> "_eq": true
> }
> }
> 
> ```

I think you reply but following your idea, I tried it, but I need the correct syntax in the “check\_dup” operation and the condition node. Here is my example flow:  
node “check\_dup”:

 ![check_dup](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/1/17a7713d022575e8ec800dddf0e44bd0b6478f84.png)

node “condition”:

 ![condition](https://us1.discourse-cdn.com/flex002/uploads/directus/original/2X/8/88a8d44de804bb419a1c62497ae06e5cf59bb4f1.png)  
can you send me an exalpme using flow  
thanks
