I am trying to create a Flow to prevent duplicate entries in the “cours” table.
Fields in “cours”:
The Flow is of type “Filter (Blocking)”. The Read Data node filter is:
{
"_and": [
{
"Ense": {
"_eq": "{{ $trigger.payload.Ense }}"
}
},
{
"activite": {
"_eq": "{{ $trigger.payload.activite }}"
}
},
{
"date_cours": {
"_eq": "{{ $trigger.payload.date_cours }}"
}
}
]
}
Even when no duplicate exists, I get this error:
“[FORBIDDEN] You don’t have permission to access this.”
hi and thanks a lot for your reply
I created a flow to control duplicate records, and I implemented the following configuration:
1. Read Data Operation:
{
"filter": {
"_and": [
{ "Ense": { "_eq": "{{ $trigger.payload.Ense }}" } },
{ "activite": { "_eq": "{{ $trigger.payload.activite }}" } },
{ "date_cours": { "_eq": "{{ $trigger.payload.date_cours }}" } }
]
}
}
2. Add Script Operation:
module.exports = async function(data) {
return (data.read_data.length > 0);
}
This script returns true if a duplicate exists.
3. Condition Operation:
{
"check_dup": {
"_eq": true
}
}
The issue:
Even when there is no duplicate, Directus still returns this error:
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).
nb:can i add a node “create data” if record is no duplicated??